Markdown Formatter & Pretty Printer

Cleans up inconsistent Markdown: mixed bullet characters, uneven heading spacing, trailing whitespace, and stray extra blank lines, while leaving fenced code blocks completely untouched. A free online tool from Staaarter, right in your browser.

Runs locallyUpdated 2026-07-22

Overview

Introduction

Markdown written by hand, pasted from different editors, or auto-generated tends to drift: some lists use *, others use -, heading hashes get inconsistent spacing, and stray blank lines pile up.

This formatter normalizes those surface-level inconsistencies without touching the actual content or restructuring anything inside a code fence.

What Is Markdown Formatter & Pretty Printer?

A line-based Markdown normalizer, not a full parse-and-reserialize formatter. It walks the document line by line, fixing spacing and marker style while leaving paragraph text and code fences untouched.

That's a deliberate tradeoff: a full AST-based reformatter can reorder or restructure things in ways that are hard to predict, while a line-based pass only ever changes what you can see changing.

How Markdown Formatter & Pretty Printer Works

Each line is checked against a few rules: unordered list markers (* or +) are normalized to -, ATX heading hashes get exactly one space before the heading text, trailing whitespace is trimmed (except a hard line break's two trailing spaces, which are preserved), and runs of 2+ blank lines collapse to one.

Fenced code blocks are tracked by their opening and closing ``` or ~~~ markers and copied through completely unmodified, since reformatting code would corrupt it.

When To Use Markdown Formatter & Pretty Printer

Use it after merging Markdown from multiple contributors who use different list marker styles or heading spacing conventions.

It's also useful as a quick cleanup pass before committing a README or doc that accumulated stray blank lines during editing.

Features

Advantages

  • Never touches content inside fenced code blocks.
  • Preserves intentional hard line breaks instead of trimming them like ordinary trailing whitespace.
  • Runs entirely client-side with no upload required.

Limitations

  • Doesn't align table columns or reflow paragraph text; only spacing and marker consistency are normalized.
  • Setext-style headings (underlined with === or ---) aren't converted to ATX (#) style.

Examples

Mixed bullets and heading spacing

Input

#Title

*  item one
+ item two



Done.

Output

# Title

- item one
- item two

Done.

The heading gets a single space after #, both bullet styles normalize to -, and the run of blank lines collapses to one.

Best Practices & Notes

Best Practices

  • Run this before committing Markdown that multiple contributors have edited, to keep diffs focused on actual content changes.
  • Pair with the Markdown Validator afterward to catch structural issues formatting alone won't fix.
  • Keep a copy of the original if a hard line break's meaning matters, since trailing-space rules are easy to misjudge visually.

Developer Notes

Fence tracking mirrors the same approach as Remove Markdown Links: a boolean `inFence` flag plus the specific opening marker (``` vs ~~~), toggled only when a closing fence uses the matching marker, so a ~~~ block containing a literal ``` line isn't closed early.

Markdown Formatter & Pretty Printer Use Cases

  • Cleaning up a README after merging edits from several contributors
  • Normalizing bullet style across a large Markdown document
  • Removing accumulated stray blank lines before a final review

Common Mistakes

  • Assuming this reflows or word-wraps paragraph text; it only touches spacing and marker characters, not line breaks within prose.
  • Not noticing a hard line break (two trailing spaces) was intentional before formatting collapses ordinary trailing whitespace elsewhere.

Tips

  • If a table's column alignment looks off after formatting, that's expected. Table content isn't reformatted, only surrounding markers are.
  • Combine with Escape Markdown first if your content has literal characters that need protecting before normalization.

References

Frequently Asked Questions