Rehype HTML Playground

Pick plugins, run them on your HTML and compare the source with the result. The preview is sanitized and rendered in a sandboxed frame with scripts disabled.

Load an example:
Plugins to run
Up to 200,000 charactersCtrl + Enter to run
No result yet.

What runs, and in which order

Only the plugins listed above can run. They always run in this order, whatever order you tick them in: sanitize, slug, autolink headings, external links, highlight, then format or minify. That mirrors a sensible real pipeline: sanitize untrusted input first, then let trusted plugins add ids, links and highlighting.

  • rehype-autolink-headings runs with behavior: 'wrap' and needs heading ids, so enable rehype-slug with it.
  • rehype-external-links adds target="_blank" and rel="nofollow noopener noreferrer" to http and https links.
  • rehype-highlight highlights code blocks that have a language-* class, using lowlight's "common" set of 37 languages. Highlight colors appear in the preview.
  • The minify option uses the same browser subset of rehype-preset-minify as the HTML Minifier.

Preview safety

The output pane shows the pipeline result as escaped code, exactly as produced. The preview is different: it is passed through rehype-sanitize again (with highlight classes allowed) and displayed in an <iframe sandbox> without allow-scripts, so scripts, event handlers, forms and navigation cannot run. Remote image addresses are removed from the preview, and the frame's security policy blocks remote loading as well, so pasted HTML cannot make your browser contact other servers. The playground never loads packages from npm and never executes code you type.

Packages used

rehype-slug, rehype-autolink-headings, rehype-external-links, rehype-highlight, rehype-sanitize, rehype-format, rehype-preset-minify, bundled locally from npm and run in a Web Worker. Your input stays on your device.

Other tools: HTML Formatter · HTML Minifier · HTML Sanitizer · HTML to Markdown · Plugin Explorer

Use ↑ ↓ to move, Enter to open.