Skip to content

msneto/mdmin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⚡️ mdmin

mdmin is a ultra-fast, modern Markdown minifier designed to squeeze every unnecessary byte out of your documents while preserving their semantic structure.

Built with Bun, it's optimized for speed and efficiency, making it perfect for preparing large datasets for LLM context windows or reducing web payload sizes.


🚀 Quick Start

Ensure you have Bun installed.

# Clone and install
git clone https://github.com/msneto/markdown-minifier
cd markdown-minifier
bun install

# Run it
bun src/cli/index.ts --help

Or use the binary:

# Link it globally (optional)
bun link
mdmin --input README.md --stats

🛠 Usage

# Basic minification
mdmin -i input.md -o output.md

# Ultra-dense mode (removes extra newlines)
mdmin -d -i input.md

# Remove links and images for pure text extraction
mdmin --no-links --no-images -i input.md

# Stream from stdin
cat large_file.md | mdmin --stats > minified.md

# Automation friendly
mdmin -i input.md --stats --json 2> stats.json

🛠 Professional CLI Features

  • Machine Readable: Use --json with --stats or --bench to get structured output on stderr.
  • Standard Compliant: Respects NO_COLOR environment variable and detects TTY for a clean experience in CI/CD.
  • High Performance: Built on Bun's high-speed I/O primitives.

✨ Fun Facts

  1. Token Squeeze: Markdown links and images often consume 30-50% more tokens in LLM contexts than the text they contain. mdmin can strip them while keeping the meaningful content.
  2. Bun Powered: By using Bun's native File and stdin streaming, mdmin can process gigabytes of Markdown with minimal memory footprint.
  3. Semantic Awareness: Unlike generic minifiers, mdmin understands Markdown blocks, ensuring your headers and lists remain perfectly valid.
  4. Zero-Jank: The lexer is built as a state machine, meaning it doesn't need to load the entire file into memory to start minifying.

📚 Documentation

For detailed technical specifications and the optimization roadmap, see:


🧪 Benchmarking

Want to see it fly?

bun run bench

“Minifying the web, one block at a time.” 🚀

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors