Use this file to discover Exa products, pricing, evaluations, comparisons, use cases, agent interfaces, and technical documentation before exploring further.
JavaScript Markdown parsers read Markdown text and turn it into HTML, a syntax tree, or UI components. These libraries render documentation, comments, and the Markdown that language models return in chat replies.
Popularity
marked has the most monthly downloads in this comparison, at 486.2M.
Downloads: npm, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.
Libraries and code examples
marked
marked compiles Markdown to HTML in the browser, on a server, or from its command-line tool. marked.parse returns an HTML string, and marked.use adds extensions that change how text is split into tokens or how tokens become HTML. A walkTokens hook visits every token before output, and with the async option on it can wait on asynchronous work. marked doesn't sanitize the HTML it produces, so output from untrusted Markdown goes through a sanitizer such as DOMPurify.
Downloads / mo
486.2M
Stars
37.3K
Last release
18.2.1
License
MIT
Strengths
Supports asynchronous token work.With async on, parse waits for walkTokens work before returning.
Extends tokenization and rendering.marked.use registers custom syntax and renderers.
Limitations
HTML output needs sanitizing.Output from untrusted Markdown needs a sanitizer such as DOMPurify.
Default settings are shared globally.A separate Marked instance keeps its own options and extensions.
function(data, options) {
const { post_asset_folder, marked: markedCfg, source_dir } = this.config;
const { prependRoot, postAsset, dompurify } = markedCfg;
const { path, text } = data;
marked.defaults.extensions = null;
marked.defaults.tokenizer = null;
marked.defaults.renderer = null;
marked.defaults.hooks = null;
marked.defaults.walkTokens = null;
// exec filter to extend marked this.execFilterSync('marked:use', marked.use, { context: this });
// exec filter to extend renderer this.execFilterSync('marked:renderer', renderer, { context: this });
// exec filter to extend tokenizer this.execFilterSync('marked:tokenizer', tokenizer, { context: this });
const extensions = [];
this.execFilterSync('marked:extensions', extensions, { context: this });
marked.use({ extensions });
let postPath = '';
if (path && post_asset_folder && prependRoot && postAsset) {
const Post = this.model('Post');
// Windows compatibility, Post.findOne() requires forward slash const source = path.substring(this.source_dir.length).replace(/\\/g, '/');
const post = Post.findOne({ source });
if (post) {
const { source: postSource } = post;
postPath = join(source_dir, dirname(postSource), basename(postSource, extname(postSource)));
}
}
let sanitizer = function(html) { return html; };
if (dompurify) {
if (createDOMPurify === undefined && JSDOM === undefined) {
createDOMPurify = require('dompurify');
JSDOM = require('jsdom').JSDOM;
}
const window = new JSDOM('').window;
const DOMPurify = createDOMPurify(window);
let param = {};
if (dompurify !== true) {
param = dompurify;
}
sanitizer = function(html) { return DOMPurify.sanitize(html, param); };
}
marked.use({
renderer,
tokenizer
});
return sanitizer(marked.parse(text, Object.assign({
// headerIds was removed in marked v8.0.0, but we still need it headerIds: true
}, markedCfg, options, { postPath, hexo: this, _headingId: {} })));
}
micromark
micromark is a small CommonMark parser that also supports GitHub Flavored Markdown, MDX, math, and frontmatter through extensions. It runs as a state machine that emits concrete tokens with the position of every byte, then compiles those tokens straight to HTML. micromark takes a Markdown string and returns HTML, and raw HTML in the input stays escaped unless allowDangerousHtml is set. The tokens also feed mdast-util-from-markdown, which builds the syntax trees that remark uses.
Downloads / mo
363.2M
Stars
2.2K
Last release
4.0.3
License
MIT
Strengths
Tracks every byte.Each token records its exact position in the source text.
Escapes HTML by default.Raw HTML in the input stays escaped unless allowDangerousHtml is set.
function renderMarkdownInline(markdown: string): string {
const documentFragment = parseDocumentFragmentFromString(micromark(markdown));
addTargetBlankToHyperlinks(documentFragment);
const html = serializeDocumentFragmentIntoString(documentFragment);
return stripParagraphContainer(html);
}
mdast-util-from-markdown
mdast-util-from-markdown turns Markdown into an mdast syntax tree, a JSON structure with one node per heading, paragraph, link, and other element. fromMarkdown takes a string and returns the tree, using micromark's tokens underneath. Extensions add syntax such as GitHub Flavored Markdown or frontmatter. The function only parses, so other utilities turn the tree back into Markdown or HTML, and remark-parse wraps it for use in a unified pipeline.
Downloads / mo
353.9M
Stars
296
Last release
2.1.0
License
MIT
Strengths
Tree from one call.fromMarkdown returns an mdast tree with no processor or plugin setup.
Limitations
Parsing only.Turning the tree into HTML or Markdown takes other utilities, or remark.
remark-parse is the plugin that adds Markdown parsing to unified, a framework that runs content through parse, transform, and output steps. unified().use(remarkParse) reads Markdown into an mdast syntax tree, and further plugins inspect or change that tree. remark-parse handles input only: writing Markdown back out needs remark-stringify, and the remark package combines both with unified. Syntax extensions such as remark-gfm plug in alongside it.
Downloads / mo
315.7M
Stars
9.0K
Last release
11.0.0
License
MIT
Strengths
Plugs into unified.unified().use(remarkParse) adds Markdown input to any unified processor.
Limitations
Input side only.Writing Markdown back out needs remark-stringify, or the remark package, which includes both.
markdown-it follows the CommonMark spec and adds extensions such as URL autolinking and typographic replacements. new MarkdownIt() creates a parser, and render turns Markdown into HTML in one call. parse returns the token array instead, so code can inspect or change tokens before rendering. Rules can be added or replaced, and community plugins add syntax such as footnotes. Raw HTML in the input is off by default, and the html option turns it on.
Downloads / mo
153.0M
Stars
22.0K
Last release
15.0.3
License
MIT
Strengths
Allows custom parsing rules.Rules can be added, or existing ones replaced.
Exposes tokens before rendering.parse returns the token array before rendering.
Limitations
Raw HTML starts disabled.The html option turns raw HTML tags on.
Enabled HTML needs sanitizing.With HTML on, the output needs an external sanitizer.
remark transforms Markdown with plugins that inspect and change an mdast syntax tree. The remark package combines unified with remark-parse and remark-stringify, so one processor reads Markdown, runs plugins, and writes Markdown back out. remark().process returns the result as a file. HTML output takes a plugin such as remark-html, and GitHub Flavored Markdown features such as tables come from remark-gfm. The project lists more than a hundred plugins, and remark-cli checks and formats Markdown files from the command line.
Downloads / mo
37.7M
Stars
9.0K
Last release
15.0.1
License
MIT
Strengths
Produces Markdown after changes.One processor parses Markdown and writes it back out.
Exposes a document syntax tree.Plugins work on the mdast tree between parsing and output.
Limitations
HTML output needs a plugin.HTML output takes a compiler plugin such as remark-html.
GFM syntax needs a plugin.remark-gfm adds tables and task lists.
export default async function markdownToHtml(markdown: string) {
const result = await remark().use(html).process(markdown);
return result.toString();
}
@lezer/markdown
@lezer/markdown is an incremental CommonMark parser built for code editors. It produces compact Lezer syntax trees and reuses parts of the previous tree when the text changes, so an edit reparses only what changed. parser.parse returns the tree, and configure adds extensions. The parser doesn't produce HTML and doesn't check that link references exist. CodeMirror's Markdown language package uses it for highlighting and editing support.
Downloads / mo
32.0M
Stars
147
Last release
1.8.1
License
MIT
Strengths
Incremental parsing.Reuses parts of the previous tree, so edits reparse only what changed.
Limitations
No HTML output.Returns a syntax tree only, for editors such as CodeMirror.
Unchecked link references.Parses [a][b] as a link even when no [b] reference exists.
markdown-to-jsx compiles Markdown, including GitHub Flavored Markdown tables and task lists, into React elements. Inline HTML in the Markdown is parsed into JSX, so rendering needs no dangerouslySetInnerHTML. The overrides option replaces any tag with a custom component or adds props to it. Separate entry points output HTML strings, Markdown, a syntax tree, or elements for React Native, SolidJS, and Vue.
Downloads / mo
23.6M
Stars
2.4K
Last release
9.10.6
License
MIT
Strengths
HTML becomes JSX.Inline HTML renders as React elements, with no dangerouslySetInnerHTML.
Overridable tags.The overrides option swaps any tag for a custom component or adds props.
export function planMarkdownHeadingAnchors(
markdown: string,
pageIds: Iterable<string> = PAGE_IDS,
): MarkdownHeadingPlan {
const headings: Array<{ source: string; legacy: string }> = [];
const ast = parser(markdown, {
slugify: (source, legacySlugify) => {
const legacy = legacySlugify(source);
headings.push({ source, legacy });
return legacy;
},
});
const { footnoteIds, ids: reservedIds } = collectReservedMarkdownIds(
ast,
pageIds,
);
const ids = createUniqueHeadingIds(
headings.map(({ source }) => source),
reservedIds,
);
const renderIdsBySource = new Map<string, string[]>();
for (const [index, { source }] of headings.entries()) {
renderIdsBySource.set(source, [
...(renderIdsBySource.get(source) ?? []),
ids[index],
]);
}
// markdown-to-jsx calls the same slugifier for footnote footer ids after it // renders the headings. Appending the original footnote id keeps that call // paired with the href the parser already emitted, including when a heading // and footnote use the exact same source text. for (const [source, id] of footnoteIds) {
renderIdsBySource.set(source, [
...(renderIdsBySource.get(source) ?? []),
id,
]);
}
const callsBySource = new Map<string, number>();
const slugify = (source: string): string => {
const sourceIds = renderIdsBySource.get(source);
if (!sourceIds?.length) {
// markdown-to-jsx also uses this callback for generated structures such // as footnote footer ids. Their links already target the library's own // slug scheme, so changing an unplanned value here would break the pair. return legacySlugify(source);
}
const call = callsBySource.get(source) ?? 0;
callsBySource.set(source, call + 1);
// React Strict Mode may evaluate markdown-to-jsx's memoized compiler more // than once. Cycling over each source's complete id sequence makes every // full evaluation deterministic instead of exhausting a one-shot cursor. return sourceIds[call % sourceIds.length];
};
const canonicalIds = new Set(ids);
const aliases = new Map<string, string>();
const claimedIds = new Set([...reservedIds, ...canonicalIds]);
for (const [index, { legacy }] of headings.entries()) {
if (!legacy || claimedIds.has(legacy)) {
continue;
}
aliases.set(ids[index], legacy);
claimedIds.add(legacy);
}
const footnotesByLabel = new Map(
[...footnoteIds].map(([source, id]) => [source.toLowerCase(), id]),
);
const footnoteId = (label: string) =>
footnotesByLabel.get(label.toLowerCase());
return { aliases, footnoteId, slugify };
}
FAQ
To turn Markdown into HTML, use marked or markdown-it. marked output needs a sanitizer such as DOMPurify for untrusted input, while markdown-it disables raw HTML by default. To inspect or change documents with plugins, use remark. In React, markdown-to-jsx renders Markdown as components.
markdown-to-jsx turns Markdown into React elements and parses inline HTML into JSX, so the page needs no dangerouslySetInnerHTML. Its overrides option replaces any rendered tag with a custom component.
micromark is a small CommonMark parser that turns Markdown into tokens, with the position of every byte, and compiles them straight to HTML. Raw HTML in the input stays escaped unless allowDangerousHtml is set. mdast-util-from-markdown and remark build their syntax trees from micromark's tokens.
Both turn Markdown into HTML in one call and accept extensions. markdown-it disables raw HTML by default and returns its token array from parse. marked passes HTML through without sanitizing, and its walkTokens hook can run asynchronous work before output.
No. marked doesn't sanitize its output, and its README recommends running the HTML through a sanitizer such as DOMPurify, sanitize-html, or insane.
For coding agents
Found your Markdown parser library? Help your agent use it.
Connect Exa so your coding agent can find the library’s documentation, check its API, and look up implementations while you build.