Markdown Cleaner
Paste messy Markdown and get it back clean, or strip the Markdown out to plain text. Code blocks stay untouched, every change is listed and nothing is uploaded.
Rules (17 of 19 on)
Why clean up Markdown?
Markdown pasted from chat apps, exported from a CMS or edited by several people drifts: stray blank lines, headings without a space after the #, mixed _ and * emphasis, * and + bullets, invisible characters from a web page. Renderers tolerate some of it; linters, diffs and stricter parsers don't. This cleaner applies up to 19 safe rules in one pass, lists which ones changed something and shows every edited line. When you don't want Markdown at all, Plain text mode strips the syntax and keeps the words.
How to clean Markdown
- Paste your Markdown, press Open to load a .md file, or try the Sample.
- Choose Clean up Markdown to tidy the syntax, or Plain text to remove it. In clean mode, open Rules to switch individual fixes on or off; 17 of 19 are on by default.
- Press Clean Markdown. After that the result follows your edits as you type.
- Check the fixes applied, press Show changes to see each edited line, then Copy or download the result.
What the cleaner does to messy Markdown
The Sample button loads this file. With the default rules it comes back as shown, with 14 kinds of fix applied:
Before
#Project Notes ##
Welcome to the __Project Alpha__ notes. This file has _messy_ formatting.
* First item
* Second item
* Nested too deep
* Third item
|Name|Role|
|---|---|
| Ana | Lead|
>Quote without a space
Read the [docs] (https://example.com/docs).
<!-- TODO: remove this note -->
***
```js
const keep = "spaces in code";
```After
# Project Notes
Welcome to the **Project Alpha** notes. This file has *messy* formatting.
- First item
- Second item
- Nested too deep
- Third item
| Name | Role |
| --- | --- |
| Ana | Lead |
> Quote without a space
Read the [docs](https://example.com/docs).
---
```js
const keep = "spaces in code";
```
What each cleaning rule does
- Remove invisible characters: deletes zero-width spaces, word joiners, byte-order marks and soft hyphens, which hide a heading or list marker from Markdown and split words. Zero-width joiners stay, because emoji and several scripts need them.
- Replace non-breaking spaces: non-breaking, narrow and other fixed-width spaces become ordinary spaces, so a # or - followed by a no-break space is recognised as a heading or list item again.
- Remove extra blank lines: never more than one blank line in a row, and none at the start or end of the document. Blank lines inside code blocks are kept.
- Fix heading formatting: adds the missing space in #Heading and removes closing hashes, so ## Title ## becomes ## Title (## C# keeps its #).
- Fix list indentation: moves nested items to the indent their parent needs, two spaces under a - bullet and three under 1., and moves their continuation lines and code blocks with them, so the nesting never changes. Lists that rely on lazy continuation lines are left as written.
- Trim trailing whitespace (keeps line breaks): removes spaces and tabs at the end of lines, but keeps a Markdown hard line break (two or more spaces before the next line of the same paragraph) as exactly two spaces.
- Normalize emphasis to *: __bold__ becomes **bold** and _italic_ becomes *italic*. Underscores inside words like snake_case_name, in URLs and link targets, and in lowercase dunder names like __init__ are left alone.
- Fix link spacing: [text] (url) becomes [text](url) when the part in parentheses is a URL or file path, so the link renders. Prose like [sic] (see above) is never turned into a link.
- Remove HTML comments: deletes <!-- … --> comments, including ones that span several lines. Comments in code and inside raw HTML blocks are kept.
- Collapse multiple spaces: runs of spaces inside a line become one. Indentation, list markers and trailing spaces are never touched.
- Ensure newline at end: the output ends with a single newline, as most linters and Git expect.
- Fix table formatting: real tables only (a header row followed by a |---| row): trims the padding inside cells and writes every row as | a | b |. Lines that just contain a pipe, like ls | grep, are left alone, and columns are not padded to equal widths.
- Convert tabs to spaces: tabs in indentation become the spaces they stand for (a tab stop every four columns, as Markdown reads them), so nesting is preserved; a tab inside a line becomes one space.
- Remove empty links: off by default; turns [text]() into plain text.
- Fix blockquote spacing: >quote becomes > quote.
- Normalize horizontal rules: ***, ___ or - - - on a line of their own become ---. A rule directly under a line of text, or at the very top of the file, is left alone, because --- there would turn the text into a heading or start front matter.
- Use - for every bullet: * and + bullets become -. Two lists that sit back to back with different bullets are separate lists in Markdown and would merge, so in that case nothing is changed.
- Blank lines around headings & code: puts one blank line before and after every heading and fenced code block that starts at the left margin. Neither can continue a paragraph or list, so how the document renders doesn't change.
- Straighten curly quotes: off by default; “curly” quotes and ’ apostrophes become straight " and ' outside code and links. Useful for docs and code samples written in a word processor.
Remove Markdown from ChatGPT and other AI answers
Chatbots write in Markdown. Copy an answer with the copy button and paste it into an email, a form or a document that doesn't understand Markdown, and you get the raw symbols: ## before headings, ** around bold words, pipes in tables. Plain text mode turns it back into readable text:
Markdown
## Quick summary Here are **three tips** for better sleep: 1. Keep a *regular* schedule. 2. Avoid screens an hour before bed. 3. See the [NHS guide](https://www.nhs.uk/live-well/sleep-and-tiredness/) for more. > **Note:** results vary.
Plain text
Quick summary Here are three tips for better sleep: 1. Keep a regular schedule. 2. Avoid screens an hour before bed. 3. See the NHS guide (https://www.nhs.uk/live-well/sleep-and-tiredness/) for more. Note: results vary.
- Lists keep their numbers, and bullets become • (or - or nothing). Task lists show ☐ and ☑.
- Links keep the address in brackets after the text, or untick Keep link addresses to keep only the text.
- Tables become one line per row with cells separated by tabs, so they paste straight into Excel or Google Sheets.
- Code blocks keep their content, without the ``` fences. HTML tags are removed and entities such as & become the characters they stand for.
If you want to keep the formatting instead, paste the Markdown into the Markdown editor and use Copy › Formatted text: headings, bold text and lists then paste into Google Docs, Word or Gmail as real formatting.
Code blocks, line breaks and nested lists are safe
Every rule skips fenced code blocks (``` and ~~~), indented code blocks, YAML front matter and raw HTML blocks such as <pre> and <div>. The rules that work inside a line also skip inline `code`, link URLs and HTML tags. A #include line, a shell pipeline or a tab-indented Makefile inside a code block comes through unchanged.
- Hard line breaks: two spaces at the end of a line mean "break here" in Markdown. Trim trailing whitespace keeps them (as exactly two spaces) and removes trailing spaces everywhere else.
- Nested lists and indented code: indentation is never collapsed. Fix list indentation moves a nested item together with everything inside it, so the structure stays the same.
- Underscores: snake_case words, URLs and lowercase dunder names like
__init__are left alone. Because of that, a lowercase__word__stays as it is; write**word**if you mean bold.
A few rules change how a document renders, on purpose: Fix heading formatting turns #Heading into a heading (so a line that starts with a #hashtag becomes one too; untick the rule for text like that), Fix link spacing makes a broken link work, and the two removal rules delete what they say. Show changes lists every line that was edited.
Markdown cleaner, formatter or linter?
A linter such as markdownlint reports style problems by rule number and leaves the fixing to you. This cleaner applies the fix for many of the same rules, and only the ones that are safe to automate:
| Cleaner rule | markdownlint rule it satisfies |
|---|---|
| Remove extra blank lines | MD012 no-multiple-blanks |
| Fix heading formatting | MD018 no-missing-space-atx, MD003 heading style (closing hashes) |
| Trim trailing whitespace | MD009 no-trailing-spaces |
| Convert tabs to spaces | MD010 no-hard-tabs |
| Use - for every bullet | MD004 ul-style (dash) |
| Normalize emphasis to * | MD049 emphasis-style, MD050 strong-style (asterisk) |
| Blank lines around headings & code | MD022 blanks-around-headings, MD031 blanks-around-fences |
| Normalize horizontal rules | MD035 hr-style (---) |
| Remove empty links | MD042 no-empty-links |
| Ensure newline at end | MD047 single-trailing-newline |
Unlike a full formatter, it never rewraps paragraphs, renumbers lists or pads table columns, so a clean-up produces a small, reviewable diff instead of rewriting every line.
What it doesn't do
The cleaner tidies syntax; it won't renumber lists, rewrap lines, or turn HTML and Word files into Markdown. For those, start with HTML to Markdown or DOCX to Markdown, clean the result here, and check how it renders in the Markdown editor. To compare two versions of any text in detail, use the text diff checker; to find other hidden characters, the invisible character tool.
Frequently asked questions
What does the Markdown cleaner fix?
Up to 19 formatting problems: extra blank lines, headings without a space after the #, uneven list indentation, trailing spaces, mixed _ and * emphasis, mixed bullet characters, broken link spacing, untidy tables, tabs, HTML comments, invisible characters and non-breaking spaces, among others. Each rule is described on this page; 17 are on by default.
How do I remove Markdown formatting from text?
Switch to Plain text and paste your Markdown. Headings, **bold**, *italics*, links, code fences and table pipes are removed and the words are kept: lists keep a bullet or number, tables become tab-separated rows that paste into a spreadsheet, and link addresses can be kept in brackets or dropped. It is the quickest way to clean up an answer copied from ChatGPT, Claude or Gemini.
Will it break my code blocks?
No. Every rule skips fenced code (``` and ~~~), indented code blocks, front matter and raw HTML blocks such as <pre>, and the rules that work inside a line also skip inline `code`, link URLs and HTML tags. A '#include' line, a shell pipeline or tab-indented Makefile code inside a code block comes through unchanged.
Can I turn individual rules off?
Yes. Open the Rules panel next to the Clean button and untick any rule; the output updates immediately. Your choices are remembered on this device for next time, and Reset restores the defaults.
Does it keep Markdown line breaks?
Yes. Two or more spaces at the end of a line that continues into the next line of the same paragraph is a hard line break, and Trim trailing whitespace keeps it as exactly two spaces. Trailing spaces anywhere else are removed. A backslash at the end of a line, the other way to write a break, is left untouched.
Will it flatten my nested lists?
No. Collapse multiple spaces never touches indentation, and Fix list indentation moves each nested item to the indent its parent needs (two spaces under -, three under 1.) together with its continuation lines and code blocks, so the nesting stays exactly the same. A list that relies on lazy continuation lines is left as written.
Does cleaning change how my document looks when rendered?
Almost never. Most rules only change the source: Markdown renders the same with or without them. The exceptions are deliberate: Fix heading formatting turns #Heading (or a line starting with a #hashtag) into a heading, Fix link spacing makes [text] (url) a working link, and the two removal rules delete what they say. Show changes highlights every line that was edited.
What are invisible characters and non-breaking spaces?
Text copied from web pages, Word or chat apps can carry characters you can't see: zero-width spaces (U+200B), byte-order marks (U+FEFF), soft hyphens (U+00AD) and non-breaking spaces (U+00A0). In Markdown they quietly break things: a heading or list item whose marker is followed by a non-breaking space isn't recognised, and a zero-width space can split a word or a link. The cleaner removes or replaces them outside code.
Is this a Markdown formatter or a linter?
It is a formatter that only fixes what is safe to fix. A linter such as markdownlint reports problems (MD009 trailing spaces, MD012 multiple blank lines, MD022 blank lines around headings and so on) without changing your file; this tool applies the fix for many of those rules in one pass and lists what it changed. Unlike a full formatter, it doesn't rewrap paragraphs or renumber lists.
Does it convert HTML or Word documents to Markdown?
No. It cleans text that is already Markdown. Use the HTML to Markdown or DOCX to Markdown tools to convert first, then paste the result here to tidy it up.
Does it renumber ordered lists or rewrap long lines?
No. Numbering, line wrapping and wording are left as they are. CommonMark renderers number ordered lists from the first item anyway, so 1. 1. 1. displays as 1, 2, 3.
Does it upload my content?
No. Cleaning and converting happen entirely in your browser with JavaScript; nothing you paste or open is sent to a server. Only your rule choices are remembered on this device.
Related tools
More free, private, browser-based utilities — no upload, no sign-up.