MDX File Prettifier & Indenter
Paste messy MDX (Markdown + JSX) to prettify with proper indentation, heading normalization, and syntax highlighting
Paste messy MDX — broken indentation, smushed headings, tabs mixed with spaces — and get clean, formatted output in one click. Headings get normalized, blank lines land where they should, and JSX components stay untouched. And everything runs in your browser. Nothing gets uploaded.
How It Works
The formatter splits your MDX into Markdown regions and JSX blocks. Markdown parts get heading normalization (adds the space after # if you forgot it), consistent blank lines between sections, and your chosen indent depth. JSX and HTML blocks pass through untouched so your components don’t break.
Examples
Fixing Smushed Headings
You pasted content from a wiki and every heading lost its space after the hash marks.
#Introduction
##Getting Started
###Install the package# Introduction
## Getting Started
### Install the packageCleaning Up Mixed Indentation with JSX
Your MDX doc has tabs in some places, 3 spaces in others, and a React component wedged between two paragraphs with zero blank lines.
Some intro text.
<Callout type="warning">
Watch out for this.
</Callout>
- Item one
- Nested itemSome intro text.
<Callout type="warning">
Watch out for this.
</Callout>
- Item one
- Nested itemBlog Post Frontmatter + Body Cleanup
A typical scenario: you exported a blog post from a CMS and the formatting came out inconsistent. Frontmatter is fine but the body is a wall of text with no breathing room.
---
title: My Post
date: 2024-09-15
---
##Why MDX Matters
MDX lets you write docs with components.
<AuthorCard name="Jane" />
###Conclusion
That is all.---
title: My Post
date: 2024-09-15
---
## Why MDX Matters
MDX lets you write docs with components.
<AuthorCard name="Jane" />
### Conclusion
That is all.Who Uses This
Cleaning up MDX documentation before committing to a repo so diffs stay readable.
Standardizing docs exported from various CMS platforms into consistent MDX format.
Formatting contributed docs from dozens of people who all indent differently.
Tidying up MDX notes and assignments before submission or publishing on a portfolio site.
Common Mistakes
MDX requires a blank line before and after JSX blocks. Without them, the parser can’t tell where Markdown ends and JSX begins. The formatter adds these gaps automatically, but you should know why they exist.
Pick one. Tabs and spaces mixed together create invisible formatting bugs that look fine in your editor but break in production. This formatter converts everything to your chosen space count.
Most MDX frameworks expect a single # Heading at the top (often pulled from frontmatter). Using multiple H1s can mess up your table of contents and SEO. Stick with H2 and below for sections.
Technical Details
- Processing: 100% client-side — nothing is uploaded
- Browser Support: Chrome, Firefox, Safari, Edge
- Indent Options: 2 spaces or 4 spaces
- Preserves: JSX components, frontmatter, code blocks, HTML
- Output: Copy to clipboard or download as .mdx file
Frequently Asked Questions
What is MDX and how is it different from Markdown?
MDX is Markdown with JSX mixed in. You write normal Markdown for text, headings, and lists, but you can drop React components right into the document. Regular Markdown can’t do that — it only outputs static HTML.
Will this formatter break my React components?
No. The formatter detects JSX and HTML blocks and leaves them alone. It only touches whitespace, heading formatting, and indentation in the Markdown parts of your file. Your component props, attributes, and children won’t be changed.
Can I use this for regular Markdown files too?
Yes. MDX is a superset of Markdown, so plain .md files work perfectly here. You’ll get the same heading normalization, spacing cleanup, and indentation fixes.
Does this tool upload my code anywhere?
Not at all. Everything happens in your browser with JavaScript. You can disconnect from the internet and it still works. Your MDX content never touches a server.
What’s the best indent size for MDX — 2 or 4 spaces?
Most MDX projects (Next.js docs, Docusaurus, Astro) default to 2 spaces. If your project already has an .editorconfig or Prettier config, match that. Otherwise, 2 spaces is the safer bet — it keeps nested lists and JSX from drifting too far right.