Project: rehypejs/rehype-dom

Package: rehype-dom@5.0.0

  1. Dependencies: 3·Dependents: 0
  2. unified processor to use browser APIs to parse and stringify HTML
  1. unified 155
  2. html 110
  3. rehype 72
  4. tree 42
  5. syntax 32
  6. ast 29
  7. parse 22
  8. stringify 18
  9. compile 13
  10. dom 10
  11. abstract 10
  12. process 7


Build Coverage Downloads Size Sponsors Backers Chat

unified processor to use browser APIs to parse and compile HTML.

If you don’t care about bundle size, or if you don’t trust content, or if you’re not in a (modern) browser environment, use rehype instead.

If you’re not concerned with bundle size or are in an environment in which you don’t trust (or don’t have) the native DOM API, you may prefer to use rehype instead.

As rehype-dom is designed for browser use, it defaults to parsing in fragment mode, whereas rehype defaults to document mode!

Don’t need the parser? Or the compiler? That’s OK.



yarn add rehype-dom


npm install rehype-dom


import unified from 'unified';
import createStream from 'unified-stream';
import rehypeDom from 'rehype-dom';

rehypeDom().process('<p>text, <b>hyper', (err, file) => {
  if (err) {
  } else {


<p>text, <b>hyper</b></p>

Configuration for rehype-dom-parse and rehype-dom-stringify can be set with .data('settings', {/*...*/}).


Use of rehype-dom can open you up to a cross-site scripting (XSS) attack if the document is unsafe or unsafe plugins are used. Use rehype-sanitize to make the tree safe.


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, organisation, or community you agree to abide by its terms.


ISC © Keith McKnight