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.

The remark monorepo publishes four packages to npm. Which one you install depends on what role it will play in your pipeline: the remark package covers most use cases on its own, while remark-parse and remark-stringify give you finer control when composing a custom unified processor. remark-cli is for command-line use without writing JavaScript.
All remark packages are ESM only — there is no CommonJS build. In Node.js projects, add "type": "module" to your package.json, or use .mjs file extensions for any script that imports remark. require() will not work.

Node.js (version 16+)

remark

Use remark when your input is markdown and your output is also markdown. It is a pre-configured unified processor that bundles remark-parse and remark-stringify.
npm install remark

remark-parse

Use remark-parse when you need to parse markdown as part of a larger unified pipeline where the output is something other than markdown (for example, HTML via rehype).
npm install remark-parse

remark-stringify

Use remark-stringify when you need to serialize an mdast syntax tree back to markdown as the final step in a custom unified pipeline.
npm install remark-stringify

remark-cli

Use remark-cli to inspect and format markdown files from a terminal or an npm script, without writing JavaScript.
npm install remark-cli
Install remark-cli as a dev dependency (--save-dev / -D) when you are using it only for formatting or linting as part of a build step.

Deno

All packages are available in Deno via esm.sh. No installation step is needed — import directly in your script.

remark

import {remark} from 'https://esm.sh/remark@15'

remark-parse

import remarkParse from 'https://esm.sh/remark-parse@11'

remark-stringify

import remarkStringify from 'https://esm.sh/remark-stringify@11'

Browsers

You can use remark in a modern browser by loading packages from esm.sh with the ?bundle query parameter, which inlines all dependencies into a single file.

remark

<script type="module">
  import {remark} from 'https://esm.sh/remark@15?bundle'
</script>

remark-parse

<script type="module">
  import remarkParse from 'https://esm.sh/remark-parse@11?bundle'
</script>

remark-stringify

<script type="module">
  import remarkStringify from 'https://esm.sh/remark-stringify@11?bundle'
</script>

TypeScript

The remark organization and the unified collective are fully typed with TypeScript. No @types/* packages are required for remark itself — type declarations ship with every package. Type definitions for the mdast node types (e.g. Root, Heading, Paragraph) are available from @types/mdast:
npm install --save-dev @types/mdast
Use the types when writing your own plugins so TypeScript can verify that you are accessing tree nodes correctly:
/**
 * @import {Root} from 'mdast'
 */

import {visit} from 'unist-util-visit'

export function myRemarkPlugin() {
  /**
   * @param {Root} tree
   */
  return function (tree) {
    visit(tree, function (node) {
      // node is fully typed as an mdast Node
    })
  }
}
If you use .data('settings', …) on a unified processor to pass options to remark-stringify, import remark-stringify (or remark) somewhere in your TypeScript project. Those packages register their Settings types with unified, which lets TypeScript validate the option names you pass.

Verifying your installation

After installing, you can verify everything is wired up correctly by running this one-liner from a .mjs file or a project with "type": "module":
import {remark} from 'remark'

const file = await remark().process('# Hello, remark!')
console.log(String(file)) // => '# Hello, remark!\n'
If you see the markdown echoed back to the console, remark is installed and working correctly.

Build docs developers (and LLMs) love