Tools

Home
JSON FormatterSQL FormatterJS ValidatorMinify CSS
Merge PDFCompress PDFImage to PDF
JPG to PNGPNG to WebPCrop Image

MDX File Prettifier & Indenter

Paste messy MDX (Markdown + JSX) to prettify with proper indentation, heading normalization, and syntax highlighting

Your files never leave your browser
Input0 chars, 0 lines
Output0 chars, 0 lines
Ready·

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

Paste Raw MDX
→
Parse & Reformat
→
Clean MDX Output

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.

INPUT
#Introduction ##Getting Started ###Install the package
OUTPUT
# Introduction ## Getting Started ### Install the package

Cleaning 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.

INPUT
Some intro text. <Callout type="warning"> Watch out for this. </Callout> - Item one - Nested item
OUTPUT
Some intro text. <Callout type="warning"> Watch out for this. </Callout> - Item one - Nested item

Blog 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.

INPUT
--- title: My Post date: 2024-09-15 --- ##Why MDX Matters MDX lets you write docs with components. <AuthorCard name="Jane" /> ###Conclusion That is all.
OUTPUT
--- 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

👨‍💻 Developers

Cleaning up MDX documentation before committing to a repo so diffs stay readable.

✍️ Technical Writers

Standardizing docs exported from various CMS platforms into consistent MDX format.

📚 Open Source Maintainers

Formatting contributed docs from dozens of people who all indent differently.

🎓 Students

Tidying up MDX notes and assignments before submission or publishing on a portfolio site.

Common Mistakes

Forgetting blank lines around JSX components

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.

Mixing tabs and spaces in the same file

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.

Using heading level 1 multiple times

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

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.

Share: