Skip to main content

Free Tool

Markdown Formatter

Paste messy Markdown and get it back in one clean, consistent style, with tables aligned. Every result is checked to render exactly like your original. Runs in your browser; nothing is uploaded.

Renders exactly the same: both versions were converted to HTML and compared.

2 headings rewritten as # headings · 3 bullets switched to one marker · 1 table aligned · 1 horizontal rule set to --- · 2 extra blank lines removed

What the formatter changes

Markdown has several spellings for the same thing. The formatter picks one for each and rewrites the rest. The page you publish looks the same; the source stops looking like five people wrote it.

Markdown before and after formatting
FixBeforeAfter
Underlined headingsTitle =====# Title
Mixed bullet markers* one * two- one - two
Rules written three ways*** or ___---
Ragged tables|a|b| |-|-:| |long cell|1|| a | b | | --------- | ---: | | long cell | 1 |
Runs of blank linesPara one Para twoPara one Para two
Trailing spacesLine ends here···Line ends here

Table columns are padded to the widest cell, and wide characters such as CJK text and emoji count as two columns so the pipes still line up in a monospace editor. Column alignment colons are kept; a column without one stays without one. To build a table from scratch, use the table generator.

What it never touches

  • Code. Fenced and indented code blocks are copied byte for byte, trailing spaces included.
  • Raw HTML and blockquotes. A <div align="center"> block or a quoted reply stays exactly as written.
  • Your words and emphasis. Paragraphs are not re-wrapped, and *italic* and __bold__ keep the marker you chose.
  • Numbered lists and front matter. 1) stays 1), numbering is not reset, and a YAML block at the top of the file is kept as is.
  • Hard line breaks. Two trailing spaces before another line are a line break, so they stay (trimmed to exactly two).

How it checks nothing changed

A formatter that silently changes your document is worse than none. Some rewrites look harmless and are not: switching + to - between two adjacent lists merges them into one, and turning an underlined heading that ends in # into a # heading deletes the last word. So after every keystroke the tool converts both versions to HTML with a GitHub Flavored Markdown parser and compares them, ignoring only whitespace a browser never displays. A green check means they match. Before publishing, it was run on 945 real README and changelog files: every one rendered identically, and formatting the output a second time changed nothing.

Format Markdown in your editor or CI

This page is for a one-off clean-up. To format every file in a repository, one of these does the job:

Prettier

npx prettier --write "**/*.md"

The usual choice in JavaScript projects. It formats Markdown out of the box and also rewrites emphasis (*text* becomes _text_) and numbered lists. Add --prose-wrap always to hard-wrap paragraphs.

mdformat (Python)

pip install mdformat mdformat-gfm
mdformat README.md

A CommonMark formatter that also checks the rendered HTML has not changed, the same guarantee this page gives. The mdformat-gfm plugin adds tables and task lists.

markdownlint

npx markdownlint-cli2 --fix "**/*.md"

A linter rather than a formatter: it reports style problems and fixes the ones that have a safe automatic fix. Use it in CI to keep files from drifting after a one-off clean-up.

Writing rather than tidying? The online Markdown editor has a toolbar and live preview, and the cheat sheet lists every piece of syntax. The VS Code guide covers previewing Markdown as you write.

Frequently asked questions

What does a Markdown formatter do?
It rewrites the Markdown source into one consistent style without changing what the document says: # headings instead of underlined ones, one bullet marker, --- for every horizontal rule, padded and aligned tables, single blank lines between blocks, and no trailing spaces. The rendered page looks the same; the source becomes easier to read and to diff.
Will formatting change how my Markdown renders?
No. Each rewrite has an exact equivalent in GitHub Flavored Markdown, and the tool proves it on every keystroke by converting your original and the formatted version to HTML and comparing them. If they ever differ, it says so instead of a green check.
Does the formatter change code blocks?
No. Fenced and indented code blocks are copied byte for byte, including trailing spaces and blank lines, because inside code they are content. Raw HTML blocks and blockquotes are also left exactly as written.
Why does a second list sometimes get * instead of -?
Two bullet lists written one after the other only stay two lists if their markers differ; with the same marker, Markdown merges them into one. The formatter alternates - and * in that case, which is also what Prettier does.
Does it keep line breaks made with two trailing spaces?
Yes. Two or more spaces at the end of a line followed by another line are a hard line break, so those become exactly two spaces. Trailing spaces anywhere else, which render as nothing, are removed.
How do I format Markdown in VS Code?
VS Code has no built-in Markdown formatter. Install the Prettier extension, open the .md file, and run Format Document (Shift+Alt+F on Windows and Linux, Shift+Option+F on macOS). Set Prettier as the default formatter for Markdown if VS Code asks which one to use.
Is my Markdown uploaded?
No. The formatter runs in your browser and the text you paste is never sent to a server. It keeps working with your network disconnected once the page has loaded.