A fast, versatile Markdown toolchain for React and more
open sourceMITfree
markdown-to-jsx is a GFM and CommonMark compliant Markdown parser and compiler for JavaScript and TypeScript, fast enough for real-time use on large documents. Its <Markdown> component and compiler turn Markdown into React elements, and it also outputs to React Native, SolidJS, Vue, HTML, Markdown or an AST, including React Server Components. HTML inside the Markdown is parsed into JSX instead of injected with dangerouslySetInnerHTML, raw HTML goes through a sanitizer you can replace (or is ignored), and any tag it renders can be overridden with your own component. It supports every GFM syntax (tables, task lists, strikethrough, autolinks, tag filtering), streaming Markdown, shortcodes and syntax highlighting through highlight.js, and has no runtime dependencies.
Problems it solves
- render Markdown in a React app without dangerouslySetInnerHTML
- replace HTML tags in rendered Markdown with my own React components
- render Markdown from an LLM as it streams in
- a small Markdown renderer for React with no dependencies
- render Markdown in React Native, SolidJS or Vue
- parse Markdown to an AST in TypeScript
Features
- GFM and CommonMark compliant
- outputs React, React Native, SolidJS, Vue, HTML, Markdown or an AST
- React Server Components
- HTML parsed into JSX without dangerouslySetInnerHTML
- replaceable sanitizer for raw HTML, or ignore HTML blocks
- override any rendered tag with a component
- streaming Markdown
- no runtime dependencies
Alternatives
The same job
These do what markdown-to-jsx does.
- react-markdown React component to render Markdown
- Marked A Markdown parser and compiler, built for speed
- markdown-it Markdown parser done right: fast and easy to extend