Gathering detailed insights and metrics for micromark
Gathering detailed insights and metrics for micromark
Gathering detailed insights and metrics for micromark
Gathering detailed insights and metrics for micromark
small, safe, and great commonmark (optionally gfm, mdx) compliant markdown parser
npm install micromark
Typescript
Module System
Node Version
NPM Version
4.0.2
Updated on Feb 27, 2025
micromark-util-types@2.0.2
Updated on Feb 27, 2025
micromark-core-commonmark@2.0.3
Updated on Feb 27, 2025
micromark-util-subtokenize@2.1.0
Updated on Feb 27, 2025
micromark-util-subtokenize@2.0.3
Updated on Nov 19, 2024
4.0.1
Updated on Nov 12, 2024
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
2,006 Stars
656 Commits
73 Forks
13 Watchers
2 Branches
29 Contributors
Updated on Jul 11, 2025
Latest Version
4.0.2
Package Id
micromark@4.0.2
Unpacked Size
204.72 kB
Size
34.98 kB
File Count
75
NPM Version
11.1.0
Node Version
23.1.0
Published on
Feb 27, 2025
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
17
Markdown parser.
Note: this is the
micromark
package from the micromark monorepo. See the monorepo readme for more on the project. See this readme for how to use it.
See § Comparison for more info
micromark
is an open source markdown parser written in JavaScript.
It’s implemented as a state machine that emits concrete tokens, so that every
byte is accounted for, with positional info.
It then compiles those tokens directly to HTML, but other tools can take the
data and for example build an AST which is easier to work with
(mdast-util-to-markdown
).
While most markdown parsers work towards compliancy with CommonMark (or GFM),
this project goes further by following how the reference parsers (cmark
,
cmark-gfm
) work, which is confirmed with thousands of extra tests.
Other than CommonMark and GFM, micromark also supports common extensions to markdown such as MDX, math, and frontmatter.
These npm packages have a sibling project in Rust:
markdown-rs
.
unifiedjs.com
This package is ESM only. In Node.js (version 16+), install with npm:
1npm install micromark
In Deno with esm.sh
:
1import {micromark} from 'https://esm.sh/micromark@3'
In browsers with esm.sh
:
1<script type="module"> 2 import {micromark} from 'https://esm.sh/micromark@3?bundle' 3</script>
Typical use (buffering):
1import {micromark} from 'micromark' 2 3console.log(micromark('## Hello, *world*!'))
Yields:
1<h2>Hello, <em>world</em>!</h2>
You can pass extensions (in this case micromark-extension-gfm
):
1import {micromark} from 'micromark' 2import {gfmHtml, gfm} from 'micromark-extension-gfm' 3 4const value = '* [x] contact@example.com ~~strikethrough~~' 5 6const result = micromark(value, { 7 extensions: [gfm()], 8 htmlExtensions: [gfmHtml()] 9}) 10 11console.log(result)
Yields:
1<ul> 2<li><input checked="" disabled="" type="checkbox"> <a href="mailto:contact@example.com">contact@example.com</a> <del>strikethrough</del></li> 3</ul>
Streaming interface:
1import {createReadStream} from 'node:fs' 2import {stream} from 'micromark/stream' 3 4createReadStream('example.md') 5 .on('error', handleError) 6 .pipe(stream()) 7 .pipe(process.stdout) 8 9function handleError(error) { 10 // Handle your error here! 11 throw error 12}
micromark
core has two entries in its export map: micromark
and
micromark/stream
.
micromark
exports the identifier micromark
.
micromark/stream
exports the identifier stream
.
There are no default exports.
The export map supports the development
condition.
Run node --conditions development module.js
to get instrumented dev code.
Without this condition, production code is loaded.
See § Size & debug for more info.
micromark(value[, encoding][, options])
Compile markdown to HTML.
Note: which encodings are supported depends on the engine. For info on Node.js, see WHATWG supported encodings.
value
(string
or Uint8Array
)
— markdown to parseencoding
(string
, default: 'utf8'
)
— character encoding to understand value
as when it’s a
Uint8Array
options
(Options
, optional)
— configurationCompiled HTML (string
).
stream(options?)
Create a duplex (readable and writable) stream.
Some of the work to parse markdown can be done streaming, but in the end buffering is required.
micromark does not handle errors for you, so you must handle errors on whatever
streams you pipe into it.
As markdown does not know errors, micromark
itself does not emit errors.
options
(Options
, optional)
— configurationDuplex stream.
Options
Configuration (TypeScript type).
allowDangerousHtml
Whether to allow (dangerous) HTML (boolean
, default: false
).
The default is false
, which still parses the HTML according to CommonMark
but shows the HTML as text instead of as elements.
Pass true
for trusted content to get actual HTML elements.
See § Security.
allowDangerousProtocol
Whether to allow dangerous protocols in links and images (boolean
, default:
false
).
The default is false
, which drops URLs in links and images that use dangerous
protocols.
Pass true
for trusted content to support all protocols.
URLs that have no protocol (which means it’s relative to the current page, such
as ./some/page.html
) and URLs that have a safe protocol (for images: http
,
https
; for links: http
, https
, irc
, ircs
, mailto
, xmpp
), are
safe.
All other URLs are dangerous and dropped.
See § Security.
defaultLineEnding
Default line ending to use when compiling to HTML, for line endings not in
value
('\r'
, '\n'
, or '\r\n'
; default: first line ending or '\n'
).
Generally, micromark
copies line endings (\r
, \n
, \r\n
) in the markdown
document over to the compiled HTML.
In some cases, such as > a
, CommonMark requires that extra line endings are
added: <blockquote>\n<p>a</p>\n</blockquote>
.
To create that line ending, the document is checked for the first line ending
that is used.
If there is no line ending, defaultLineEnding
is used.
If that isn’t configured, \n
is used.
extensions
Array of syntax extensions (Array<SyntaxExtension>
, default: []
).
See § Extensions.
htmlExtensions
Array of syntax extensions (Array<HtmlExtension>
, default: []
).
See § Extensions.
This package is fully typed with TypeScript.
It exports the additional type Options
.
Projects maintained by the unified collective are compatible with maintained versions of Node.js.
When we cut a new major release, we drop support for unmaintained versions of
Node.
This means we try to keep the current release line, micromark@4
, compatible
with Node.js 16.
This package is safe.
See security.md
in micromark/.github
for how to
submit a security report.
See contributing.md
in micromark/.github
for ways
to get started.
See support.md
for ways to get help.
This project has a code of conduct. By interacting with this repository, organisation, or community you agree to abide by its terms.
Support this effort and give back by sponsoring on OpenCollective!
Salesforce 🏅 ![]() | |||||||||
Vercel |
Motif |
HashiCorp |
GitBook |
Gatsby | |||||
Netlify![]() |
Coinbase |
ThemeIsle |
Expo |
Boost Note![]() |
Markdown Space![]() |
Holloway | |||
You? |
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
security policy file detected
Details
Reason
1 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 1
Reason
Found 4/30 approved changesets -- score normalized to 1
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More