Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/remarkjs/remark/llms.txt

Use this file to discover all available pages before exploring further.

remark is a markdown processor built on unified that works by converting markdown into an abstract syntax tree (AST), running plugins against that tree, and then serializing the result back. Because every transformation happens on structured data rather than raw text, plugins can do sophisticated things — reformat code, generate tables of contents, lint for style issues, or bridge into entirely different ecosystems like HTML — all in a composable, predictable way.

What is remark?

remark is part of the unified collective, a family of projects that process content as structured data. When you hand markdown to remark, it is parsed into mdast — a specification for representing markdown as a JSON-compatible syntax tree. Plugins then walk and modify that tree before the result is serialized back to markdown or handed off to another ecosystem (such as rehype for HTML output). The markdown heading:
## Hello *Pluto*!
becomes this mdast node (positional info omitted for brevity):
{
  type: 'heading',
  depth: 2,
  children: [
    {type: 'text', value: 'Hello '},
    {type: 'emphasis', children: [{type: 'text', value: 'Pluto'}]}
    {type: 'text', value: '!'}
  ]
}
Plugins receive the full tree and can inspect or mutate any node before the final output is produced. This is what makes remark’s plugin ecosystem so powerful: plugins compose without interfering with each other because they all operate on the same well-defined data structure.

The four packages

The remark monorepo ships four packages, each serving a distinct role in the pipeline.

remark

A pre-configured unified processor that bundles both remark-parse and remark-stringify. Use it when both your input and output are markdown — it is the shortest path to a markdown-in / markdown-out pipeline.

remark-parse

A unified plugin that adds markdown parsing support. It converts a markdown string into an mdast syntax tree. Use it with unified directly when your output is something other than markdown (for example, HTML via rehype).

remark-stringify

A unified plugin that adds markdown serialization support. It converts an mdast syntax tree back into a markdown string. Use it when you need markdown as the final output and are composing your own unified pipeline.

remark-cli

A command-line interface built on top of remark. Use it to inspect and format markdown files in your project from a terminal or npm script, without writing any JavaScript.

When to use remark vs alternatives

Choosing the right tool depends on how much of the pipeline you need.
GoalRecommended tool
Parse and serialize markdown with pluginsremark
Parse markdown as input to a custom unified pipelineremark-parse
Serialize mdast back to markdownremark-stringify
Inspect or reformat markdown files on the CLIremark-cli
Simply convert markdown to HTML (no plugins needed)micromark
Access the syntax tree directly without pluginsmdast-util-from-markdown / mdast-util-to-markdown
If you only need to convert markdown to HTML and don’t plan to use plugins, micromark is a faster, lower-level alternative. If you want direct AST access without the plugin abstraction, mdast-util-from-markdown operates on the tree without any unified overhead.

Feature highlights

remark is the world’s most popular markdown parser and covers a wide range of use cases.
  • CommonMark compliant — 100% conformance with CommonMark out of the box. GFM (GitHub Flavored Markdown) and MDX are available via plugins.
  • AST-based transforms — all processing happens on a structured mdast tree, making it easy to inspect, rewrite, or generate content programmatically.
  • 150+ plugins — choose from a rich ecosystem of community plugins for linting, table-of-contents generation, syntax highlighting, math, directives, and much more.
  • TypeScript support — the remark organization and the unified collective are fully typed. Types for mdast are available via @types/mdast.
  • Runs everywhere — Node.js 16+, Deno (via esm.sh), and modern browsers are all supported.

A quick example: markdown to HTML

The most common remark pipeline combines remark-parse, remark-rehype (to cross into the HTML AST world), and rehype-stringify (to produce an HTML string). Here is the complete, runnable code:
import rehypeStringify from 'rehype-stringify'
import remarkParse from 'remark-parse'
import remarkRehype from 'remark-rehype'
import {unified} from 'unified'

const file = await unified()
  .use(remarkParse)
  .use(remarkRehype)
  .use(rehypeStringify)
  .process('# Hello, *Mercury*!')

console.log(String(file)) // => '<h1>Hello, <em>Mercury</em>!</h1>'
Each .use() call registers a plugin on the unified processor. remarkParse parses the markdown string into an mdast tree; remarkRehype converts that mdast tree into an hast (HTML AST) tree; rehypeStringify serializes the hast tree into an HTML string.
When going to HTML, always consider adding rehype-sanitize to your pipeline to guard against cross-site scripting (XSS) vulnerabilities from user-supplied markdown.

Plugin ecosystem

remark plugins deal with markdown. Some popular examples include:
  • remark-gfm — adds GitHub Flavored Markdown support (autolink literals, footnotes, strikethrough, tables, tasklists)
  • remark-lint — warns about inconsistent or non-conforming markdown style
  • remark-toc — generates a table of contents
  • remark-rehype — bridges from the remark (mdast) ecosystem to the rehype (hast) ecosystem for HTML output
You can discover more from the list of plugins, the awesome-remark curated list, or by browsing the remark-plugin topic on GitHub.

Build docs developers (and LLMs) love