Markdown Minifier

Minify Markdown by trimming whitespace and collapsing blank lines.

  • Runs locally in your browser
  • No upload required

Try it

Paste Markdown. Fenced code blocks are preserved exactly.

Minified Markdown
# Title Paragraph
Size
20 → 18 characters (2 saved)
# Title

Paragraph

Supported formats

Input
text, number
Output
text

Privacy

Runs entirely in your browser. Your input is never uploaded, stored, or sent to a third party.

Processing
In your browser
Privacy level
Browser only

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

  1. Read the document line by line and track fenced code regions.
  2. Outside a fence, strip trailing whitespace and collapse runs of blank lines to the chosen maximum.
  3. Copy fenced code lines verbatim and trim leading/trailing blank lines.

Usage

  1. Paste or type a Markdown document.
  2. Choose whether to keep at most one blank line between blocks.
  3. 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

jsonSelect to copy
{
  "text": "# Title\n\n\n\nParagraph",
  "maxBlankLines": 1
}

All blank lines removed

jsonSelect to copy
{
  "text": "a\n\nb\n\n\nc",
  "maxBlankLines": 0
}

Code fence preserved

jsonSelect to copy
{
  "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

  1. CommonMark Spec — CommonMark
  2. MDN Web Docs — Markdown — MDN