Gathering detailed insights and metrics for rehype
Gathering detailed insights and metrics for rehype
Gathering detailed insights and metrics for rehype
Gathering detailed insights and metrics for rehype
HTML processor powered by plugins part of the @unifiedjs collective
npm install rehype
Typescript
Module System
Node Version
NPM Version
97.4
Supply Chain
97
Quality
80.4
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
2,036 Stars
350 Commits
93 Forks
11 Watchers
1 Branches
49 Contributors
Updated on Jul 10, 2025
Latest Version
13.0.2
Package Id
rehype@13.0.2
Unpacked Size
12.97 kB
Size
4.69 kB
File Count
5
NPM Version
10.8.3
Node Version
22.7.0
Published on
Sep 27, 2024
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
4
unified processor to add support for parsing from HTML and serializing to HTML.
This package is a unified processor with support for parsing HTML as input
and serializing HTML as output by using unified with
rehype-parse
and rehype-stringify
.
See the monorepo readme for info on what the rehype ecosystem is.
You can use this package when you want to use unified, have HTML as input, and
want HTML as output.
This package is a shortcut for
unified().use(rehypeParse).use(rehypeStringify)
.
When the input isn’t HTML (meaning you don’t need rehype-parse
) or the
output is not HTML (you don’t need rehype-stringify
), it’s recommended to
use unified
directly.
When you’re in a browser, trust your content, don’t need positional info on
nodes or formatting options, and value a smaller bundle size, you can use
rehype-dom
instead.
When you want to inspect and format HTML files in a project on the command
line, you can use rehype-cli
.
This package is ESM only. In Node.js (version 16+), install with npm:
1npm install rehype
In Deno with esm.sh
:
1import {rehype} from 'https://esm.sh/rehype@13'
In browsers with esm.sh
:
1<script type="module"> 2 import {rehype} from 'https://esm.sh/rehype@13?bundle' 3</script>
Say we have the following module example.js
:
1import {rehype} from 'rehype' 2import rehypeFormat from 'rehype-format' 3 4const file = await rehype().use(rehypeFormat).process(`<!doctype html> 5 <html lang=en> 6<head> 7 <title>Hi!</title> 8 </head> 9 <body> 10 <h1>Hello!</h1> 11 12</body></html>`) 13 14console.error(String(file))
…running that with node example.js
yields:
1<!doctype html> 2<html lang="en"> 3 <head> 4 <title>Hi!</title> 5 </head> 6 <body> 7 <h1>Hello!</h1> 8 </body> 9</html>
This package exports the identifier rehype
.
There is no default export.
rehype()
Create a new unified processor that already uses
rehype-parse
and rehype-stringify
.
You can add more plugins with use
.
See unified
for more information.
rehype-parse
, rehype-stringify
When you use rehype-parse
or rehype-stringify
manually you can pass options
directly to them with use
.
Because both plugins are already used in rehype
, that’s not possible.
To define options for them, you can instead pass options to data
:
1import {rehype} from 'rehype' 2import {reporter} from 'vfile-reporter' 3 4const file = await rehype() 5 .data('settings', { 6 emitParseErrors: true, 7 fragment: true, 8 preferUnquoted: true 9 }) 10 .process('<div title="a" title="b"></div>') 11 12console.error(reporter(file)) 13console.log(String(file))
…yields:
11:21-1:21 warning Unexpected duplicate attribute duplicate-attribute hast-util-from-html 2 3⚠ 1 warning
1<div title=a></div>
HTML is parsed and serialized according to WHATWG HTML (the living standard), which is also followed by all browsers.
The syntax tree format used in rehype is hast.
This package is fully typed with TypeScript. It exports no additional types.
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, rehype@^13
, compatible
with Node.js 16.
As rehype works on HTML, and improper use of HTML can open you up to a
cross-site scripting (XSS) attack, use of rehype can also be unsafe.
Use rehype-sanitize
to make the tree safe.
Use of rehype plugins could also open you up to other attacks. Carefully assess each plugin and the risks involved in using them.
For info on how to submit a report, see our security policy.
See contributing.md
in rehypejs/.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, organization, or community you agree to abide by its terms.
Support this effort and give back by sponsoring on OpenCollective!
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
license file detected
Details
Reason
0 existing vulnerabilities detected
Reason
security policy file detected
Details
Reason
Found 13/30 approved changesets -- score normalized to 4
Reason
0 commit(s) and 2 issue activity found in the last 90 days -- 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-06-30
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