✍️

Markdown Sanitizer & Formatter

Normalise inconsistent Markdown syntax into a consistent style. Fixes mixed headings, lists, and whitespace.

Markdown Sanitizer & Formatter

Fix bullets, indentation, links & whitespace in one click

Bullet style:
Indent:
Input
0 lines
Output

How to use the Markdown Sanitizer

Paste your AI-generated markdown into the input field -- the one with line numbers on the left. Click Sanitize and Format. The tool runs a pipeline of five fixers: heading normalization, bullet standardization, indentation repair, link URL encoding, and whitespace cleanup. A change log appears below showing every modification with line numbers so you can verify what changed.

AI output cleanup

ChatGPT and Claude often produce markdown with mixed heading styles (## Heading vs ##Heading), inconsistent bullet characters (- mixed with * and +), and irregular blank lines. Sanitize to produce publication-ready content in one click. A typical 50-line AI output gets 8-15 fixes applied.

Documentation standardization

When consolidating documentation from multiple contributors, each person uses different formatting habits. One person uses 4-space indentation, another uses tabs, a third uses 2 spaces. The sanitizer normalizes all indentation to your chosen style (2 spaces, 4 spaces, or tabs) while preserving nested list structure.

CMS and Git preparation

Before committing markdown to a Git repository or importing into a CMS like Hugo, Jekyll, or GitBook, run it through the sanitizer. It fixes broken link syntax (URLs with spaces), wraps bare URLs in angle brackets, and ensures code blocks have proper closing fences -- issues that cause rendering failures in static site generators.

Sanitization pipeline

The tool first extracts and protects all code blocks (both fenced and inline) by replacing them with placeholder tokens. This prevents the fixers from modifying content inside code. After all fixers run, the original code blocks are restored unchanged. Each fixer operates on a line-by-line basis and logs every change it makes.

Heading normalization

Fixes three common heading issues: adds a space after hashes when missing (##Heading becomes ## Heading), ensures blank lines before and after headings for proper rendering, and prevents skipped heading levels. The tool logs each fix with the exact line number so you can verify the change.

Bullet and indentation repair

Standardizes all bullet characters to your chosen style (-, *, or +). Detects nested list items by their leading whitespace, calculates their nesting depth, and re-indents them using your selected indent unit (2 spaces, 4 spaces, or tab). A line with 6 leading spaces and a * bullet at depth 3 gets converted to 6 spaces with your chosen bullet character.

Link URL encoding

Scans for markdown links containing spaces in the URL portion ([text](url with spaces)) and replaces spaces with %20. Also detects bare URLs not wrapped in markdown link syntax or angle brackets and wraps them in angle brackets to prevent rendering issues.

Whitespace cleanup

Strips trailing whitespace from every line except intentional double-space line breaks (Markdown convention for hard line breaks). Collapses runs of more than two blank lines down to two. The tool preserves intentional formatting while removing the invisible characters that cause diffs to look messy in version control.

Frequently asked questions

Will sanitization change my content meaning?

No. The tool modifies only formatting elements: whitespace, heading markers, bullet characters, and link URL encoding. Text content, link destinations, and data are preserved exactly. Code blocks are extracted before processing and restored unchanged afterward, so code samples are never altered.

Does it handle all markdown flavors?

It handles CommonMark, GitHub-Flavored Markdown, and most extensions used in documentation. The bullet fixer works with -, *, and + characters. Nested lists up to 6 levels deep are supported. Edge cases like deeply nested fenced code blocks or complex HTML blocks may require manual review.

Can I customize the sanitization rules?

Yes. Each of the five fixers (bullets, indent, links, whitespace, headings) can be toggled on or off using the toggle buttons above the input. You can also choose between dash, asterisk, or plus bullets, and between 2-space, 4-space, or tab indentation. The tool remembers your selections during the session.

How does this differ from a markdown linter like markdownlint?

A linter reports issues in a log; this tool fixes them automatically. Markdownlint checks 50+ style rules (line length, no bare URLs, consistent heading style). This sanitizer focuses on the five most common formatting problems and applies fixes without requiring configuration files. Use it for quick cleanup, then run your linter for style compliance.

What is the change log panel?

After sanitization, a change log appears showing every modification with its line number and category (BULLET, INDENT, LINK, SPACE, HEADING). A typical 100-line markdown file gets 15-25 fixes. You can review each change to verify the tool did what you expected, and use the "Use as input" button to iterate if needed.

markdownsanitizerformatterbulletsindentationlinkswhitespaceheadingscleanfixdeveloperdocumentation

More Tools You Might Like

✍️Markdown to HTML / Confluence Converter
πŸͺ΅Smart Log Cleaner & Filter
βœ‚οΈWhitespace & Line Break Trimmer
πŸ—‚οΈDuplicate Line Remover & Alphabetizer
πŸ”€Variable String Case Converter
⇄Delimiter Swapper