Markdown Minifier
Minify Markdown by trimming whitespace and collapsing blank lines.
- Runs locally in your browser
- No upload required
Try it
Supported formats
Privacy
Runs entirely in your browser. Your input is never uploaded, stored, or sent to a third party.
Reduced 20 to 18 characters of Markdown, removing 2 blank line(s).
How it works
- Removed trailing whitespace from each line.
- Collapsed runs of blank lines to a single line.
- Preserved fenced code-block content verbatim.
- Fenced code blocks are copied exactly, including internal blank lines and indentation.
- Link targets and inline HTML are never rewritten.
- Output is 18 character(s); minifying it again changes nothing.
Methodology
- Read the document line by line and track fenced code regions.
- Outside a fence, strip trailing whitespace and collapse runs of blank lines to the chosen maximum.
- Copy fenced code lines verbatim and trim leading/trailing blank lines.
Usage
- Paste or type a Markdown document.
- Choose whether to keep at most one blank line between blocks.
- Run the minifier and copy the compact result.
Examples
These are examples, not current values: they use fixed inputs, while the interactive tool computes live results in your browser.
Blank lines collapsed
{
"text": "# Title\n\n\n\nParagraph",
"maxBlankLines": 1
}All blank lines removed
{
"text": "a\n\nb\n\n\nc",
"maxBlankLines": 0
}Code fence preserved
{
"text": "text\n```\n\n code \n```\nend",
"maxBlankLines": 1
}Limitations
Blank lines in Markdown
Blank lines separate block-level elements and are the most common source of needless whitespace in generated Markdown.
The minifier keeps fenced code exact and only compresses the block structure around it.
Frequently asked questions
- Does minifying change how my Markdown renders?
- Not for blank-line or trailing-whitespace removal. The one exception is a hard line break written as two trailing spaces — use a backslash or `<br>` instead.
- Are code blocks touched?
- No. Content inside fenced code blocks is copied byte-for-byte, including its own blank lines and indentation.
- Is my Markdown uploaded?
- No. All processing happens in your browser and nothing is sent anywhere.
Sources
- CommonMark Spec — CommonMark
- MDN Web Docs — Markdown — MDN
Send feedback
Tell us if this tool helped, report a problem, or suggest a tool. Only the message you type is sent — never the input you used in the tool.
Was this tool useful?
Prefer to write to us directly? See the contact page.