How to strip html comments and excess whitespace
- Step 1Open the Markdown Minifier — Load the tool. No options exist — comment and whitespace removal is a single fixed pass.
- Step 2Move any keepable notes out of comments first — Because every
<!-- -->is deleted, relocate anything you want to retain (attribution, license headers) into visible text or frontmatter before running. - Step 3Paste or drop the draft — Provide one
.md,.mdx, or.markdownfile, or paste the text. The tool processes one document per run. - Step 4Run the cleanup — Comments are deleted, then 3+ blank lines collapse to one, trailing spaces are trimmed, and heading spacing is tightened.
- Step 5Scan for stripped code-fence comments — If your draft shows
<!-- -->inside a code sample, confirm whether it was removed — the comment pass is not fence-aware. - Step 6Publish the clean output — Download the
.min.mdresult and publish it; the source is now free of private notes and excess whitespace.
Comment and whitespace removal rules
The exact rules applied, in order. Comment removal is unconditional — there is no allow-list and no fence exception.
| Rule | Matches | Result |
|---|---|---|
| Comment strip | <!-- ... -->, including across multiple lines | Removed entirely, anywhere in the body |
| Blank-line collapse | 3 or more consecutive blank lines | Reduced to a single blank line |
| Trailing-space trim | Spaces at end of any line | Removed (leading indentation kept) |
| Heading spacing | Blank lines before/after #–###### | Removed for a tighter source |
Comments: what is and isn't stripped
HTML comments are always removed; other comment styles are content and are kept.
| Comment style | Example | Behaviour |
|---|---|---|
| HTML comment | <!-- note --> | Stripped |
| HTML comment in code fence | <!-- shown as code --> | Stripped (not fence-aware) |
| Code comment in a fence | // note or # note | Kept (it is code text, not an HTML comment) |
| Inline code with comment text | <!-- literal --> ` on its own | Stripped — the pattern matches anywhere in the body |
Cookbook
Comment removal runs first, then the whitespace passes clean up afterward. These samples show what reaches the public source and what does not.
Private review notes removed before publishing
Reviewer and editor notes in HTML comments are stripped so they never appear in the public source.
Before: ## Pricing <!-- legal: confirm refund wording --> Our plans start at $9/mo. <!-- TODO: add annual pricing --> After: ## Pricing Our plans start at $9/mo.
Multi-line comment block stripped in full
Block comments spanning several lines are matched as a single unit and removed entirely.
Before: Intro paragraph. <!-- Draft outline: - history - methodology --> Conclusion. After: Intro paragraph. Conclusion.
Whitespace tidied after comments are gone
Removing comments can leave blank-line gaps; the whitespace passes then collapse them.
Before: Text. <!-- internal --> More text. After: Text. More text.
Code comments inside fences are preserved
Programming-language comments (//, #) are code text, not HTML comments, so they stay. Only <!-- --> is targeted.
Before: ```js // keep this line const x = 1; ``` After: ```js // keep this line const x = 1; ```
An HTML comment shown as a code sample is removed
Because the comment pass is not fence-aware, a literal <!-- --> you meant to display inside a code block is deleted. Move it outside a fence if it must render.
Before: ```html <p>Hello</p> <!-- this comment is sample code --> ``` After: ```html <p>Hello</p> ```
Edge cases and what actually happens
Comments you wanted to keep are still removed
By designThere is no allow-list. Every <!-- --> is stripped. Move license headers, attribution, or any keepable note into visible text or frontmatter before running the tool.
HTML comment inside a code fence is deleted
Changes contentThe comment pass runs across the whole body and is not fence-aware. A <!-- --> shown inside a ``` html ``` block is removed even though it was intended as displayed sample code.
Code comments (// or #) are preserved
PreservedOnly HTML-style <!-- --> comments are targeted. Language comments such as // note or # note inside code fences are ordinary code text and are kept.
Trailing two-space line breaks removed
Changes renderingThe trailing-space trim deletes the two-space hard-break marker. Published lines that relied on it will merge. Use a backslash line break instead before cleaning.
Inline code containing comment text
Changes contentIf a line contains a literal <!-- --> even inside inline backticks, the pattern matches and removes it. Documenting HTML comments in prose requires escaping or storing the unminified copy.
A single blank line is kept
ExpectedThe blank-line pass collapses 3+ blanks to one and never removes the final blank line between blocks. This keeps CommonMark paragraph separation intact after comments are removed.
Document over the Free character limit
413 rejectedFree markdown input is capped at 500,000 characters / 1 MB. Larger drafts need Pro (5,000,000 chars / 10 MB) or above.
Nothing to remove
PreservedA draft with no HTML comments and tidy whitespace comes out nearly unchanged. A small or zero delta is the expected result.
Frequently asked questions
Does it remove every HTML comment?
Yes — every <!-- --> in the body, single-line and multi-line, with no exceptions. Move anything you want to keep out of comment syntax first.
What about comments I want to keep?
There is no keep-list. Relocate important notes (license, attribution) into visible text or frontmatter before running, or they will be stripped.
Will it remove comments inside my code?
Language comments like // note or # note are kept — they are code text, not HTML comments. But a literal <!-- --> inside a code fence is removed, because the comment pass is not fence-aware.
Are multi-line comments handled?
Yes. A comment block spanning several lines is matched as a whole and removed completely.
Does it also clean whitespace?
Yes. After comments are removed it collapses 3+ blank lines to one, trims trailing spaces, and tightens spacing around ATX headings.
Will my frontmatter be affected?
No. YAML and TOML frontmatter is preserved byte-for-byte; only the body is cleaned.
Does removing comments change rendering?
Comments do not render, so removing them does not change output. The rendering-affecting exceptions are two-space hard breaks and any <!-- --> shown as code.
Can I clean several drafts at once?
Not in one run — it is single-file. Run each draft separately or use a tier with a larger batch allowance.
Is the file uploaded?
No. Everything runs in your browser; the draft never leaves your machine.
How is this different from the Prettifier?
The Prettifier normalises formatting for readability and does not strip comments; the Minifier removes comments and whitespace for a clean, compact published source. Use the Prettifier for authoring, the Minifier for pre-publish hygiene.
What if I need to keep a secret out of the source entirely?
Comments are removed, but for redacting tokens, keys, or PII embedded in prose, use the Secret Redactor instead — it targets sensitive values, not comments. To flag structural issues before publishing, run the Markdown Linter.
What is the output?
Cleaned Markdown, downloaded with a .min.md suffix, ready to publish.
Privacy first
All Markdown processing runs locally in your browser using JavaScript. No file is ever uploaded to JAD Apps servers — only metadata counters are saved for signed-in dashboard stats.