MDX Notes
When should you use Markdown and when should you reach for MDX? A side-by-side look at what each format can (and can
The Short Version
Markdown is great for writing content. It's been around since 2004, everyone knows it, and it works everywhere. But if you've ever tried to add an interactive chart, a tabbed code example, or a live demo to a Markdown file... you've hit the wall.
MDX removes that wall. It's Markdown plus React components. You keep the simple writing experience but gain the ability to embed real, working UI.
Here's when to pick each one ā and why.
Quick Comparison Table
| Feature | Markdown | MDX |
|---|---|---|
| Plain text readability | āāāāā | āāāā |
| Learning curve | āāāāā | āāā |
| Interactive content | ā | ā |
| Custom components | ā | ā |
| JavaScript expressions | ā | ā |
| Import/Export | ā | ā |
| Type checking | ā | ā |
| Layout control | ā | ā |
| Plugin ecosystem | ā | ā (same + more) |
| Frontmatter support | ā | ā |
| Static site generators | ā | ā |
| GitHub rendering | ā | ā |
| Email compatibility | ā | ā |
| CMS support | ā (wide) | ā ļø (growing) |
| Build step required | ā (optional) | ā (always) |
| Non-developer authoring | ā | ā ļø |
| Dynamic data display | ā | ā |
| Conditional rendering | ā | ā |
| State management | ā | ā |
| Accessibility control | ā (limited) | ā (full) |
Where Markdown Falls Short
Let's look at specific problems you'll hit with plain Markdown ā and how MDX solves them.
Problem 1: Everything is Static
In Markdown, what you write is what you get. No computed values, no live data, no dynamic anything.
Markdown ā you have to update this by hand:
# API Status
Last updated: January 15, 2025
| Service | Status |
|---------|--------|
| Auth | ā
Up |
| API | ā
Up |
| DB | ā Down|
*Note: This table must be manually updated.*MDX ā it updates itself:
Problem 2: Copy-Paste Everywhere
Markdown has no concept of reusable patterns. Every time you want a warning box, you're writing the same blockquote syntax again.
Markdown ā repeating yourself:
> ā ļø **Warning**
>
> Do not run this command in production without backing up first.
... (200 lines later) ...
> ā ļø **Warning**
>
> This operation is irreversible. Proceed with caution.
... (300 lines later) ...
> ā ļø **Warning**
>
> Requires admin privileges. Contact your team lead for access.MDX ā write the pattern once, use it everywhere:
import { Warning } from '../components/Callout'
<Warning>
Do not run this command in production without backing up first.
</Warning>
... (200 lines later) ...
<Warning>
This operation is irreversible. Proceed with caution.
</Warning>
... (300 lines later) ...
<Warning>
Requires admin privileges. Contact your team lead for access.
</Warning>Need to change the warning icon or styling? One file. Done.
Problem 3: Code Examples You Can't Run
Markdown shows code. That's it. Readers have to copy it, paste it somewhere else, and run it themselves.
Markdown ā passive display:
## Button Examplefunction MyButton() { return ( <button onClick={() => alert('Hello!')}> Click me </button> ); }
MDX ā live and editable:
Problem 4: No Conditional Content
Markdown shows everything to everyone. You can't tailor content based on the reader's OS, skill level, or preferences.
Markdown ā shows all platforms to all users:
## Installation
### For Mac Users
Run `brew install mypackage`
### For Windows Users
Run `choco install mypackage`
### For Linux Users
Run `apt-get install mypackage`MDX ā detect and adapt:
import { Tabs, Tab } from '../components/Tabs'
import { PlatformDetect } from '../components/PlatformDetect'
## Installation
<PlatformDetect fallback={
<Tabs>
<Tab label="macOS">brew install mypackage ``` </Tab> <Tab label="Windows">
apt-get install mypackage
Problem 5: No Data Visualization
Want a chart in Markdown? Hope you like ASCII art.
Markdown ā the best you can do:
## Monthly RevenueRevenue ($K)
100 | āāā® 80 | āāā⯠ā 60 | āāā⯠ā 40 | āāā⯠ā°āāā® 20 |ā⯠ā°āā āāāāāāāāāāāāāāāāāāāāāāā Jan Feb Mar Apr May Jun
MDX ā real charts with tooltips and interaction:
Problem 6: No Layout Control
Markdown gives you a single column. Top to bottom. That's your layout.
Markdown ā linear flow only:
## Feature 1
Description of feature 1...
## Feature 2
Description of feature 2...
## Feature 3
Description of feature 3...MDX ā any layout you want:
import { Grid, Card } from '../components/Layout'
<Grid columns={3} gap="1.5rem">
<Card icon="š" title="Feature 1">
Description of feature 1 with an icon and card styling.
</Card>
<Card icon="š" title="Feature 2">
Description of feature 2 with an icon and card styling.
</Card>
<Card icon="ā”" title="Feature 3">
Description of feature 3 with an icon and card styling.
</Card>
</Grid>Where Markdown Still Wins
MDX isn't always the answer. Markdown is genuinely better in these situations:
1. Universal Portability
# This Works Everywhere
- GitHub README files
- Email newsletters
- Slack/Discord messages
- Static site generators (Hugo, Jekyll, 11ty)
- Note-taking apps (Obsidian, Notion, Bear)
- Comment systems
- Wiki platformsMDX needs a JavaScript build step. If your content needs to render on GitHub or in an email, Markdown is the only option.
2. Non-Developer Authors
A marketing person can learn Markdown in 10 minutes:
MDX requires knowing imports, JSX syntax, and component props. That's a much bigger ask for non-developers.
3. No Build Step
Markdown can be rendered with a simple parser ā or just read as plain text. It's already pretty readable without any processing. MDX always needs Node.js and a compilation step.
4. Platform Support
Thousands of tools support Markdown. MDX support is growing fast, but it's still limited to the JavaScript ecosystem.
Decision Flowchart
Not sure which to pick? Walk through this:
Migrating from Markdown to MDX
Good news: all valid Markdown is valid MDX (with a few tiny exceptions). So migration is painless.
Step 1: Rename Your Files
# Rename .md files to .mdx
find ./content -name "*.md" -exec sh -c 'mv "$1" "${1%.md}.mdx"' _ {} \;Step 2: Fix the Few Things That Break
A couple of Markdown patterns work slightly differently in MDX:
Step 3: Start Adding Components Gradually
You don't have to refactor everything at once. Start with one component:
{/* Start simple ā just add a callout component */}
import { Note } from '../components/Note'
# Existing Content
All your existing Markdown content works as-is.
<Note>
This is the first interactive element you add!
</Note>
More existing content continues below without any changes.Performance: What's the Trade-off?
| Aspect | Markdown | MDX |
|---|---|---|
| Build time | ā” Fast (simple parse) | š¢ Slower (full compilation) |
| Runtime size | š¦ Minimal | š¦ Larger (includes React) |
| Caching | ā Easy (static HTML) | ā ļø More complex |
| Incremental builds | ā Simple | ā Supported (framework-dependent) |
| SEO | ā Static HTML | ā Static HTML (with SSG/SSR) |
The build time difference matters at scale (hundreds of pages), but for most projects it's negligible. And once built, MDX outputs the same static HTML that search engines love.
The Hybrid Approach
Here's the real answer for most teams: use both. Put each format where it makes sense:
Your legal pages don't need interactive components. Your changelog doesn't need charts. Don't over-engineer them.
Summary
- MDX is a superset of Markdown ā all your existing Markdown works in MDX files
- Pick Markdown when content is purely static, needs to render on GitHub/email, or non-developers write it
- Pick MDX when you need interactivity, reusable components, dynamic data, or layout control
- Build time increases with MDX ā but the output is still static HTML (good for SEO)
- Use both in the same project ā that's totally normal and the right call for most teams
- Start with MDX if you're unsure ā you can always keep it simple, and you'll have room to grow
- Migration is easy ā rename
.mdto.mdx, fix comments and angle brackets, and you're done
Exam Focus
Revise definitions, diagrams, examples, and short-answer points for MDX vs Markdown: A Detailed Comparison.
Interview Use
Prepare one clear explanation, one practical example, and one common mistake for this MDX Tutorial topic.
Search Terms
mdx-tutorial, mdx tutorial, mdx, tutorial, introduction, markdown, mdx vs markdown: a detailed comparison
Related MDX Tutorial Topics