Skip to content

Markdown Formatter

Tidy up README files and docs. Headings, lists, emphasis and code fences become consistent, and tables are aligned into neat columns.

Input
Formatted Markdown

    
Ready

Last reviewed:

What is Markdown?

Markdown is a lightweight markup language created by John Gruber in 2004 for writing formatted text in plain text files. A # at the start of a line makes a heading, * or - starts a list item, **bold** and _italic_ add emphasis, backticks mark code, and [text](url) creates a link. It is the standard format for README files, documentation sites, wikis, issue trackers, pull request descriptions and many static site generators. The original description left many edge cases unclear, so today most tools follow CommonMark, a precise specification, and GitHub adds tables, task lists and strikethrough on top as GitHub Flavored Markdown (GFM).

Because Markdown offers several ways to write the same thing (* or - or + for bullets, *text* or _text_ for emphasis, underlined or # headings, tables with or without aligned pipes), documents edited by many people become inconsistent. That makes the source harder to read and produces noisy diffs. Rendered output also hides problems: a table with misaligned columns renders fine, but its source is unreadable in a pull request.

A Markdown formatter parses the document and prints it back in one consistent style, keeping the rendered result the same. This tool uses Prettier, which many projects already run on their docs. It normalises list markers and emphasis, aligns table columns, adds blank lines where block elements need them, and can wrap or unwrap paragraphs. Code blocks are left untouched.

How to use this tool

  1. Paste Markdown into Input or click Paste. Sample loads a short README with mixed list markers, an unaligned table and a code block.
  2. Choose paragraph wrapping: Keep line breaks leaves your line breaks as they are, Wrap paragraphs reflows text to the chosen width, and One line per paragraph joins each paragraph into a single line, which suits editors with soft wrap.
  3. Choose the line width (80, 100 or 120 columns) used by wrapping, and the list indent (2 or 4 spaces) for nested items.
  4. With Format as I type ticked, the output updates as you edit; otherwise click Format.
  5. Click Copy, or Download to save formatted.md.

Examples

Tidying a README

Input:

A short description   of the project.
* Fast
* Private

|Option|Default|Description|
|-|-|-|
|port|3000|Port the server listens on|
|debug|false|Print verbose logs|

Some *emphasis* and __bold__ text with a [link](https://devtoolworld.com).

Output:

A short description of the project.

- Fast
- Private

| Option | Default | Description                |
| ------ | ------- | -------------------------- |
| port   | 3000    | Port the server listens on |
| debug  | false   | Print verbose logs         |

Some _emphasis_ and **bold** text with a [link](https://devtoolworld.com).

Extra spaces are collapsed, a blank line separates the paragraph from the list, bullets use -, the table columns are padded to line up, emphasis uses _ and strong text uses **.

Mixed bullet markers make separate lists

In CommonMark, changing the bullet character starts a new list. This input:

* Fast
+ Private
- Free

is three one-item lists, not one list of three. Prettier keeps that meaning by putting blank lines between them and alternating the markers:

- Fast

* Private

- Free

If you meant a single list, use the same marker on every item. The formatted output makes the mistake visible.

Wrapping a long paragraph at 80 columns

With Wrap paragraphs:

This library parses configuration files, validates them against a schema and
reports every problem with its exact line and column, so you can fix them in one
pass.

It renders as one paragraph, exactly like the single-line original.

Common errors and how to fix them

  • A list unexpectedly splits in two. Different bullet markers (*, +, -) or a change from 1. to 1) start a new list. Use one marker style.
  • Numbered list starting at the wrong number. Only the first number counts. A list starting 3. renders from 3 whatever the following numbers are. Writing 1. for every item is valid and keeps diffs small when you reorder items.
  • Nested items not nested. A sub-item must be indented at least as far as the text of its parent item. For - item, that is two spaces; for 1. item, three.
  • Table not rendering. GFM tables need a delimiter row (|---|---|) directly under the header, and every row should have the same number of cells. A blank line is also needed before the table if it follows a paragraph.
  • Line breaks disappear. A single newline inside a paragraph is a soft break and renders as a space. End the line with two spaces or a backslash for a hard break, or leave a blank line for a new paragraph. The formatter keeps your two trailing spaces.
  • Code fence swallowing the rest of the file. A fence opened with three backticks needs a closing fence of at least three backticks. Count them, especially when the code itself contains backticks.

When developers use this

  • Cleaning up a README before publishing a package or opening a project to the public.
  • Aligning a hand-written Markdown table of options, endpoints or environment variables.
  • Normalising documentation contributed by many people so pull requests show content changes, not style debates.
  • Unwrapping hard-wrapped text before pasting it into a CMS, issue tracker or chat app that treats line breaks literally.
  • Matching the output of a project's Prettier pre-commit hook without running it locally.

Privacy and how it works

Prettier's Markdown formatter runs in your browser. Your document is not uploaded, stored or rendered by a server, so internal design documents, runbooks and unpublished release notes stay on your machine.

Limitations

  • The tool formats the Markdown source; it does not show a rendered preview.
  • Content inside fenced code blocks is not formatted, and raw HTML blocks are kept largely as written.
  • Extensions outside CommonMark and GFM, such as admonitions, footnote styles or MDX components, may be treated as plain text.

FAQ

Will formatting change how my Markdown renders?

It is designed not to. Prettier only chooses between equivalent forms, such as * or _ for emphasis, and adds blank lines where they do not change the structure. Where your source is ambiguous, as with mixed list markers, it keeps the meaning CommonMark gives it.

Does it format the code inside code blocks?

No. Fenced code is kept character for character, because changing it could break examples. Fences written with ~~~ are rewritten with backticks, and the language tag is kept.

Should I wrap paragraphs or keep one line per paragraph?

Wrapped paragraphs read well in terminals and plain-text editors. One line per paragraph gives smaller diffs when a sentence changes. Both render identically, so follow your project's convention.

Why does it use underscores for italics?

Prettier's style uses _text_ for emphasis and **text** for strong text, so the two are easy to tell apart in source. Both forms are standard and render the same way.

Does it support GitHub tables and task lists?

Yes. GFM tables are aligned into columns, and task list items such as - [ ] todo and - [x] done are kept.

Does it keep HTML inside Markdown?

Yes. Blocks such as <div align="center"> or <details> are preserved, which many READMEs use for centred logos and collapsible sections.

Guides