micromark is a small, CommonMark-compliant markdown parser implemented in JavaScript as a state machine. It is designed to be highly performant and robust, emitting concrete tokens with positional information, which are then compiled directly to HTML. The current stable version is 4.0.2, released as part of an actively maintained monorepo. It maintains a consistent release cadence, with minor updates and patches addressing performance improvements and bug fixes, as seen in recent 4.0.x releases. A key differentiator is its strict adherence to CommonMark and GFM specifications, further validated by thousands of additional tests that align with reference parser behavior. It also supports popular extensions such as MDX, math, and frontmatter, and is built with security in mind, being safe by default. Its design allows for both straightforward markdown-to-HTML conversion and highly complex markdown processing workflows, making it a foundational tool in the `unified` ecosystem.
npm install micromarkVerified import paths — ran on the pinned version, not inferred.
This example demonstrates parsing a markdown string, including GitHub Flavored Markdown (GFM) extensions like task lists, autolinks, and strikethrough, and outputting the corresponding HTML. It shows how to integrate optional extensions.
Migrate your project to use ES modules (`import`) or ensure your build system transpiles CommonJS imports correctly. For Node.js, ensure your package.json `type` field is set to `module` or use `.mjs` file extensions.
Always include both `extensions: [yourExtension()]` and `htmlExtensions: [yourExtensionHtml()]` when configuring extensions, as shown in the quickstart example.
For AST generation and manipulation, integrate `mdast-util-from-markdown` and other `mdast` utilities into your workflow, which build upon `micromark`'s token stream.
Update your code to use ES module `import { micromark } from 'micromark'` and ensure your project or file is configured for ESM (e.g., `"type": "module"` in `package.json` or using `.mjs` extension).Ensure both `extensions: [gfm()]` and `htmlExtensions: [gfmHtml()]` are passed to the `micromark` function's options, where `gfm` and `gfmHtml` are imported from `micromark-extension-gfm`.
Verify that you are using `import { micromark } from 'micromark'` and that your environment supports ES modules, or adjust your build pipeline to handle ESM.