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.
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# Link it globally (optional)
bun link
mdmin --input README.md --stats# 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- Machine Readable: Use
--jsonwith--statsor--benchto get structured output onstderr. - Standard Compliant: Respects
NO_COLORenvironment variable and detects TTY for a clean experience in CI/CD. - High Performance: Built on Bun's high-speed I/O primitives.
- Token Squeeze: Markdown links and images often consume 30-50% more tokens in LLM contexts than the text they contain.
mdmincan strip them while keeping the meaningful content. - Bun Powered: By using Bun's native
Fileandstdinstreaming,mdmincan process gigabytes of Markdown with minimal memory footprint. - Semantic Awareness: Unlike generic minifiers,
mdminunderstands Markdown blocks, ensuring your headers and lists remain perfectly valid. - 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.
For detailed technical specifications and the optimization roadmap, see:
- Technical Specs
- Architecture (Coming soon)
Want to see it fly?
bun run bench“Minifying the web, one block at a time.” 🚀