remark plugins are the primary way to inspect and transform markdown content. Every plugin is a plain JavaScript function that hooks into the unified processor’s lifecycle. When the processor runs, it calls each plugin in order, giving it the opportunity to read or mutate the mdast syntax tree before the final output is produced. Because the tree is just a JavaScript object, you can use standard data-manipulation techniques — or the purpose-builtDocumentation 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.
unist-util-visit utility — to work with it.
Plugin structure
A remark plugin is a function that is passed to.use() on the processor. When called, it returns a transformer: another function that receives the syntax tree and the virtual file. The transformer is where your actual logic lives.
A minimal example: increasing heading depth
The following complete example shows a plugin that increments the depth of every heading in the document. It usesunist-util-visit to walk every node in the tree and act on those with type === 'heading'.
unist-util-visit before running this:
Accepting options
Most real-world plugins are configurable. Accept an options object as the first argument to your plugin function, then reference it inside the transformer:.use():
Async transformers
Transformers may be asynchronous. Return aPromise from the transformer function and unified will wait for it to resolve before continuing to the next plugin:
TypeScript typing
The remark ecosystem is fully typed with TypeScript. Annotating your plugin with JSDoc (or TypeScript directly) lets the type checker validate the tree structure and your plugin’s options at compile time. The following example shows the recommended pattern:@types/mdast package:
Registering syntax extensions
Some plugins don’t just transform the tree — they extend the markdown syntax itself by teaching the parser and serializer to recognize new constructs (such as math, directives, or MDX). These plugins work by registering extensions on the processor’sdata store:
data('micromarkExtensions')— extends the tokenizer so the new syntax is recognized during parsing.data('fromMarkdownExtensions')— teachesmdast-util-from-markdownhow to turn the new tokens into mdast nodes.data('toMarkdownExtensions')— teachesmdast-util-to-markdownhow to serialize those nodes back to markdown text.
remark-gfm, remark-math, and remark-directive handle this plumbing for you — you rarely need to wire it up manually unless you are authoring a new syntax extension from scratch.
Next steps
Extensions
Explore ready-made syntax extension plugins for GFM, math, and more.
Markdown to HTML
See how to combine remark plugins with the rehype ecosystem.