# JavaScript Markdown parser libraries

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

| Library | Monthly downloads | Stars | Last release | License |
| --- | --- | --- | --- | --- |
| [marked](#marked) | 486.2M | 37.3K | Nov 2026 | MIT |
| [micromark](#micromark) | 363.2M | 2.2K | Sep 2026 | MIT |
| [mdast-util-from-markdown](#mdast-util-from-markdown) | 353.9M | 296 | Oct 2026 | MIT |
| [remark-parse](#remark-parse) | 315.7M | 9.0K | Sep 2023 | MIT |
| [markdown-it](#markdown-it) | 153.0M | 22.0K | Oct 2026 | MIT |
| [remark](#remark) | 37.7M | 9.0K | Sep 2023 | MIT |
| [@lezer/markdown](#lezer-markdown) | 32.0M | 147 | Oct 2026 | MIT |
| [markdown-to-jsx](#markdown-to-jsx) | 23.6M | 2.4K | Nov 2026 | MIT |

Downloads: npm, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

[marked](#marked) has the most monthly downloads in this comparison, at 486.2M.

## Capabilities

| Library | HTML output | mdast tree output |
| --- | --- | --- |
| [marked](#marked) | Yes | No |
| [micromark](#micromark) | Yes | No |
| [mdast-util-from-markdown](#mdast-util-from-markdown) | No | Yes |
| [remark-parse](#remark-parse) | Via plugin | Yes |
| [markdown-it](#markdown-it) | Yes | No |
| [remark](#remark) | Via plugin | Yes |
| [@lezer/markdown](#lezer-markdown) | No | No |
| [markdown-to-jsx](#markdown-to-jsx) | Yes | No |

## Libraries

### marked

[GitHub](https://github.com/markedjs/marked) · [npm](https://www.npmjs.com/package/marked) · [Docs](https://cdn.jsdelivr.net/npm/marked@18.2.1/README.md)

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
- Capabilities: [From the marked docs](https://cdn.jsdelivr.net/npm/marked@18.2.1/README.md)

**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.

**Watch out for**

- **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.

```sh
npm install marked@18.2.1
```

**hexojs/hexo-renderer-marked** (183 stars)

[hexojs/hexo-renderer-marked](https://github.com/hexojs/hexo-renderer-marked) 

```javascript
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: {} })));
}

```

[lib/renderer.js](https://github.com/hexojs/hexo-renderer-marked/blob/830fce8c5cf59ed1309f1f95ba03b3d9a33d403d/lib/renderer.js#L223-L283) · [More projects using marked →](https://dashboard.exa.ai/playground/search?q=Projects%20using%20marked%20for%20Markdown%20processing&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```javascript
import { marked } from 'marked';

console.log(marked.parse('# Hello', { async: false }));

```

From [README.md](https://cdn.jsdelivr.net/npm/marked@18.2.1/lib/marked.d.ts)

### micromark

[GitHub](https://github.com/micromark/micromark) · [npm](https://www.npmjs.com/package/micromark) · [Docs](https://cdn.jsdelivr.net/npm/micromark@4.0.3/readme.md)

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
- Capabilities: [From the micromark docs](https://cdn.jsdelivr.net/npm/micromark@4.0.3/readme.md)

**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.

```sh
npm install micromark@4.0.3
```

**microsoft/BotFramework-WebChat** (1.8K stars)

[microsoft/BotFramework-WebChat](https://github.com/microsoft/BotFramework-WebChat) 

```javascript
function renderMarkdownInline(markdown: string): string {
  const documentFragment = parseDocumentFragmentFromString(micromark(markdown));

  addTargetBlankToHyperlinks(documentFragment);

  const html = serializeDocumentFragmentIntoString(documentFragment);

  return stripParagraphContainer(html);
}

```

[packages/component/src/private/renderMarkdownInline.ts](https://github.com/microsoft/BotFramework-WebChat/blob/2b0a11fb0602de6c5004b1303b10c7c1c273fc76/packages/component/src/private/renderMarkdownInline.ts#L9-L17) · [More projects using micromark →](https://dashboard.exa.ai/playground/search?q=micromark%20GitHub%20projects)

**Quickstart**

```javascript
import { micromark } from 'micromark';

console.log(micromark('# Hello'));

```

From [readme.md](https://cdn.jsdelivr.net/npm/micromark@4.0.3/readme.md)

### mdast-util-from-markdown

[GitHub](https://github.com/syntax-tree/mdast-util-from-markdown) · [npm](https://www.npmjs.com/package/mdast-util-from-markdown) · [Docs](https://cdn.jsdelivr.net/npm/mdast-util-from-markdown@2.1.0/readme.md)

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
- Capabilities: [From the mdast-util-from-markdown docs](https://cdn.jsdelivr.net/npm/mdast-util-from-markdown@2.1.0/readme.md)

**Strengths**

- **Tree from one call.** fromMarkdown returns an mdast tree with no processor or plugin setup.

**Watch out for**

- **Parsing only.** Turning the tree into HTML or Markdown takes other utilities, or remark.

```sh
npm install mdast-util-from-markdown@2.1.0
```

**deepseek-ai/deepseek-harness** (211.1K stars)

[deepseek-ai/deepseek-harness](https://github.com/deepseek-ai/deepseek-harness) 

```javascript
export function parseGfmWithMath(text: string): Root {
  return recoverLocalImages(fromMarkdown(text, {
    extensions: [gfm(gfmOptions), cjkFriendlyStrong(), mathCompatibility(), math()],
    mdastExtensions: [gfmFromMarkdown(), mathFromMarkdown(), windowsPathDestinations()],
  }), text)
}

```

[packages/client/ui-primitives/src/markdown/parse.ts](https://github.com/deepseek-ai/deepseek-harness/blob/2e39e70496aa02986ca6a820c5d497e816b69d7e/packages/client/ui-primitives/src/markdown/parse.ts#L44-L49) · [More projects using mdast-util-from-markdown →](https://dashboard.exa.ai/playground/search?q=mdast-util-from-markdown%20GitHub%20projects)

**Quickstart**

```javascript
import { fromMarkdown } from 'mdast-util-from-markdown';

const tree = fromMarkdown('# Hello');
console.log(JSON.stringify(tree, null, 2));

```

From [readme.md](https://cdn.jsdelivr.net/npm/mdast-util-from-markdown@2.1.0/readme.md)

### remark-parse

[GitHub](https://github.com/remarkjs/remark) · [npm](https://www.npmjs.com/package/remark-parse) · [Docs](https://cdn.jsdelivr.net/npm/remark-parse@11.0.0/readme.md)

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
- Capabilities: [From the remark-parse docs](https://cdn.jsdelivr.net/npm/remark-parse@11.0.0/readme.md)

**Strengths**

- **Plugs into unified.** unified().use(remarkParse) adds Markdown input to any unified processor.

**Watch out for**

- **Input side only.** Writing Markdown back out needs remark-stringify, or the remark package, which includes both.

```sh
npm install remark-parse@11.0.0 unified@11.0.5
```

**cloudposse/atmos** (1.4K stars)

[cloudposse/atmos](https://github.com/cloudposse/atmos) 

```javascript
export async function normalizeMdxToMarkdown(source) {
  if (typeof source !== 'string' || !source.length) return '';
  const file = await unified()
    .use(remarkParse)
    .use(remarkMdx)
    .use(remarkNormalizeMdx)
    .use(remarkStringify, {
      bullet: '-',
      fences: true,
      listItemIndent: 'one',
      rule: '-',
      emphasis: '_',
      strong: '*',
    })
    .process(stripHtmlComments(source));
  return String(file);
}

```

[website/plugins/docusaurus-plugin-llms-txt/src/mdx-normalize.mjs](https://github.com/cloudposse/atmos/blob/148a35b6bab8de814420c6c218f38c9306894e47/website/plugins/docusaurus-plugin-llms-txt/src/mdx-normalize.mjs#L362-L378) · [More projects using remark-parse →](https://dashboard.exa.ai/playground/search?q=remark-parse%20GitHub%20projects)

**Quickstart**

```javascript
import { unified } from 'unified';
import remarkParse from 'remark-parse';

const tree = unified().use(remarkParse).parse('# Hello');
console.log(JSON.stringify(tree, null, 2));

```

From [readme.md](https://cdn.jsdelivr.net/npm/remark-parse@11.0.0/readme.md)

### markdown-it

[GitHub](https://github.com/markdown-it/markdown-it) · [npm](https://www.npmjs.com/package/markdown-it) · [Docs](https://cdn.jsdelivr.net/npm/markdown-it@15.0.3/README.md)

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
- Capabilities: [From the markdown-it docs](https://cdn.jsdelivr.net/npm/markdown-it@15.0.3/README.md)

**Strengths**

- **Allows custom parsing rules.** Rules can be added, or existing ones replaced.
- **Exposes tokens before rendering.** parse returns the token array before rendering.

**Watch out for**

- **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.

```sh
npm install markdown-it@15.0.3
```

**TryGhost/Ghost** (55.8K stars)

[TryGhost/Ghost](https://github.com/TryGhost/Ghost) 

```javascript
const selectRenderer = function (options: RenderOptions): MarkdownIt {
  const version = semver.coerce(options.ghostVersion || '4.0');

  if (version && semver.satisfies(version, '<4.x')) {
    if (renderers['<4.x']) {
      return renderers['<4.x'];
    }
    const markdownIt = new MarkdownIt({ html: true, breaks: true, linkify: true })
      .use(markdownItFootnote)
      .use(markdownItLazyHeaders)
      .use(markdownItMark)
      .use(markdownItImageLazyLoading)
      .use(namedHeaders(options))
      .use(markdownItSub)
      .use(markdownItSup);
    markdownIt.linkify.set({ fuzzyLink: false });
    renderers['<4.x'] = markdownIt;
    return markdownIt;
  } else {
    if (renderers.latest) {
      return renderers.latest;
    }
    const markdownIt = new MarkdownIt({ html: true, breaks: true, linkify: true })
      .use(markdownItFootnote)
      .use(markdownItLazyHeaders)
      .use(markdownItMark)
      .use(markdownItImageLazyLoading)
      .use(namedHeaders(options))
      .use(markdownItSub)
      .use(markdownItSup);
    markdownIt.linkify.set({ fuzzyLink: false });
    renderers.latest = markdownIt;
    return markdownIt;
  }
};

```

[koenig/kg-markdown-html-renderer/src/markdown-html-renderer.ts](https://github.com/TryGhost/Ghost/blob/5ad154310fa5b325c2201ff3caeaa4daee8172d3/koenig/kg-markdown-html-renderer/src/markdown-html-renderer.ts#L58-L92) · [More projects using markdown-it →](https://dashboard.exa.ai/playground/search?q=Projects%20using%20markdown-it%20for%20Markdown%20processing&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```javascript
import MarkdownIt from 'markdown-it';

const parser = new MarkdownIt();
console.log(parser.render('# Hello'));

```

From [README.md](https://cdn.jsdelivr.net/npm/markdown-it@15.0.3/README.md)

### remark

[GitHub](https://github.com/remarkjs/remark) · [npm](https://www.npmjs.com/package/remark) · [Docs](https://cdn.jsdelivr.net/npm/remark@15.0.1/readme.md)

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
- Capabilities: [From the remark docs](https://cdn.jsdelivr.net/npm/remark@15.0.1/readme.md)

**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.

**Watch out for**

- **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.

```sh
npm install remark@15.0.1
```

**vercel/next.js** (143.6K stars)

[vercel/next.js](https://github.com/vercel/next.js) 

```javascript
export default async function markdownToHtml(markdown: string) {
  const result = await remark().use(html).process(markdown);
  return result.toString();
}

```

[examples/blog-starter/src/lib/markdownToHtml.ts](https://github.com/vercel/next.js/blob/9c35f21f386294e63a5b0259b4d94da6a6f4731f/examples/blog-starter/src/lib/markdownToHtml.ts#L4-L7) · [More projects using remark →](https://dashboard.exa.ai/playground/search?q=Projects%20using%20remark%20for%20Markdown%20processing&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```javascript
import { remark } from 'remark';

const file = await remark().process('# Hello');
console.log(String(file));

```

From [readme.md](https://cdn.jsdelivr.net/npm/remark@15.0.1/readme.md)

### @lezer/markdown

[GitHub](https://github.com/lezer-parser/markdown) · [npm](https://www.npmjs.com/package/@lezer/markdown) · [Docs](https://cdn.jsdelivr.net/npm/@lezer/markdown@1.8.1/README.md)

@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
- Capabilities: [From the @lezer/markdown docs](https://cdn.jsdelivr.net/npm/@lezer/markdown@1.8.1/README.md)

**Strengths**

- **Incremental parsing.** Reuses parts of the previous tree, so edits reparse only what changed.

**Watch out for**

- **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.

```sh
npm install @lezer/markdown@1.8.1
```

**enso-org/enso** (7.4K stars)

[enso-org/enso](https://github.com/enso-org/enso) 

```javascript
parse(ctx: BlockContext, line: Line) {
        if (!isFirstLine(ctx)) {
          return false
        }
        const regex = /^\s*---\s*$/
        const start = ctx.lineStart
        if (regex.test(line.text)) {
          const contentStart = ctx.lineStart + line.text.length
          const startMarker = ctx.elt('YAMLMarker', ctx.lineStart, contentStart)
          while (ctx.nextLine()) {
            if (regex.test(line.text)) {
              const content = ctx.elt('YAMLContent', contentStart, ctx.lineStart)
              const end = ctx.lineStart + line.text.length
              const endMarker = ctx.elt('YAMLMarker', ctx.lineStart, end)
              ctx.addElement(
                ctx.elt('YAMLFrontMatter', start, end, [startMarker, content, endMarker]),
              )
              ctx.nextLine()
              return true
            }
          }
          return true
        } else {
          return false
        }
      }

```

[app/ydoc-shared/src/ast/ensoMarkdown.ts](https://github.com/enso-org/enso/blob/4135f929f1046ee4ab62d9d09c155377e8542a1f/app/ydoc-shared/src/ast/ensoMarkdown.ts#L43-L68) · [More projects using @lezer/markdown →](https://dashboard.exa.ai/playground/search?q=%40lezer/markdown%20GitHub%20projects)

**Quickstart**

```javascript
import { parser } from '@lezer/markdown';

const tree = parser.parse('# Hello');
console.log(tree.toString());

```

From [README.md](https://cdn.jsdelivr.net/npm/@lezer/markdown@1.8.1/README.md)

### markdown-to-jsx

[GitHub](https://github.com/quantizor/markdown-to-jsx) · [npm](https://www.npmjs.com/package/markdown-to-jsx) · [Docs](https://cdn.jsdelivr.net/npm/markdown-to-jsx@9.10.6/README.md)

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
- Capabilities: [From the markdown-to-jsx docs](https://cdn.jsdelivr.net/npm/markdown-to-jsx@9.10.6/README.md)

**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.

```sh
npm install markdown-to-jsx@9.10.6
```

**mldangelo/personal-site** (1.7K stars)

[mldangelo/personal-site](https://github.com/mldangelo/personal-site) 

```javascript
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 };
}

```

[src/lib/anchors.ts](https://github.com/mldangelo/personal-site/blob/d7326f0c0d2c2e69fddc95575a19b16cf93f8a2a/src/lib/anchors.ts#L145-L228) · [More projects using markdown-to-jsx →](https://dashboard.exa.ai/playground/search?q=markdown-to-jsx%20GitHub%20projects)

**Quickstart**

```javascript
import { compiler } from 'markdown-to-jsx/html';

console.log(compiler('# Hello'));

```

From [README.md](https://cdn.jsdelivr.net/npm/markdown-to-jsx@9.10.6/README.md)

## FAQ

### Which JavaScript Markdown parser should I use?

To turn Markdown into HTML, use [marked](#marked) or [markdown-it](#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](#remark). In React, [markdown-to-jsx](#markdown-to-jsx) renders Markdown as components.

### How do I render Markdown in React?

[markdown-to-jsx](#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.

### What is micromark?

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](#mdast-util-from-markdown) and remark build their syntax trees from micromark's tokens.

### marked vs markdown-it: which should I use?

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.

### Does marked sanitize HTML?

No. marked doesn't sanitize its output, and its README recommends running the HTML through a sanitizer such as DOMPurify, sanitize-html, or insane.

## How this page was built

Data checked Nov 19, 2026.

Reproduce it with the Exa API:

```json
{
  "endpoint": "/search",
  "body": {
    "query": "Best JavaScript Markdown parser libraries Marked markdown-it remark Showdown code examples",
    "numResults": 5
  }
}
```

Docs: https://exa.ai/docs/reference/search
