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 167
  2. html 111
  3. rehype 78
  4. tree 41
  5. ast 31
  6. syntax 29
  7. parse 21
  8. stringify 18
  9. compile 13
  10. abstract 10
  11. dom 9
  12. process 6


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