MDX Formatter
Format embedded JSX components, imports, and export functions inside MDX files with proper indentation.
Last updated: May 29, 2026
Markdown and JSX workflow shortcuts
Find this tool useful? Support the project to keep it free!
Buy me a coffeeWhat is MDX Formatter?
MDX Formatter beautifies MDX source files — the format that combines Markdown prose with JSX components used in Next.js, Gatsby, and Docusaurus documentation. MDX is valid JSX at the file level, so the formatter applies JSX-aware formatting to component definitions, export functions, and import statements while preserving surrounding markdown text. It is intentionally lightweight and focuses on indentation and line breaks rather than full AST parsing.
How to Use MDX Formatter
Paste MDX source content.
Choose indentation style.
Click Format.
Review the formatted output.
Copy or download the .mdx file.
Common Use Cases
- Formatting compact MDX component exports before committing to a docs repo.
- Normalizing indentation in MDX files generated by content tools or migrators.
- Cleaning up inlined JSX components pasted from React files into MDX.
- Preparing MDX examples for screenshots or documentation.
Example Input and Output
A compact export function inside MDX is expanded with JSX indentation.
import {useState} from 'react'
export function Counter(){const [n,setN]=useState(0);return(<div><p>{n}</p><button onClick={()=>setN(n+1)}>+</button></div>)}import { useState } from 'react'
export function Counter() {
const [n, setN] = useState(0);
return (
<div>
<p>{n}</p>
<button onClick={() => setN(n + 1)}>+</button>
</div>
)
}Privacy
MDX content is formatted locally in the browser and is not uploaded.
Frequently Asked Questions
Will it reformat plain markdown paragraphs?
Yes — markdown lines are treated as text and may have their whitespace normalized. Indented code blocks and their content may be affected, so review the output for fenced code blocks.
Does it validate MDX syntax?
No. It formats text for readability only. Use the MDX compiler or your editor to check for MDX errors.
Can it format Next.js app router MDX pages?
Yes. It handles import statements, export const metadata, and default export components commonly used in Next.js MDX pages.
Is my code uploaded anywhere?
No. Formatting runs entirely in your browser.
Related Tools
Markdown Formatter
Clean and normalize complete Markdown documents without changing their meaning. Standardize headings, lists, spacing, and emphasis while preserving code and frontmatter.
Markdown Editor
Write Markdown with live preview, document starters, multiple local drafts, outline navigation, find and replace, keyboard shortcuts, and browser-local history.
JSX Formatter
Format JSX and React markup by indenting nested elements, expression containers, and code blocks into readable output.
JavaScript Beautifier
Format and beautify minified or messy JavaScript code.
TypeScript Beautifier
Beautify and format TypeScript code with proper indentation, line breaks, and consistent spacing.
Code Highlighter
Paste code in JavaScript, TypeScript, Python, HTML, CSS, SQL, JSON, or Bash and get a syntax-highlighted HTML snippet you can embed anywhere. Live preview and copy-ready output.

