MDX Formatter
Format embedded JSX components, imports, and export functions inside MDX files with proper indentation.
Last updated: May 29, 2026
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.

