PACKAGE · MARKDOWN

rehype

HTML processor powered by plugins part of the unified collective

WEEKLY DOWNLOADS 5.3M
STARS 2.3K
FORKS 96
OPEN ISSUES 4
GZIP SIZE 70.0 kB
UNPACKED SIZE 13.3 kB
DEPENDENCIES 31
LAST UPDATED 2y ago
DOWNLOAD TRENDS

rehype downloads · last 12 months

Download trends for rehype1 download series from Nov 2025 to Oct 2026. Use left and right arrow keys to inspect monthly values.04.8M9.5M14.3M19.1MNov 2025FebMayAugOct 2026
rehype
ABOUT REHYPE

rehype is an HTML processor in the unified collective. It provides a way to parse HTML into a syntax tree, apply transformations through plugins, and produce processed HTML, making HTML manipulation part of a composable processing pipeline rather than a collection of ad hoc string edits.

Its design centers on structured documents and small, composable plugins. That approach suits developers who need to inspect or transform HTML while keeping processing steps explicit and reusable; it is less suited to tasks that only require replacing text in an HTML string.

A typical workflow uses the unified processor pattern: configure a processor with `.use()` to add plugins, then run the document through the configured steps. Plugins operate on the HTML syntax tree, so transformations can target document structure rather than depend on fragile textual matches; the exact behavior depends on the plugins selected for the pipeline.

rehype fits into JavaScript workflows that process HTML, including pipelines that connect HTML handling with other unified collective tools. It can be used to build repeatable transformations for content ingestion, rendering, or validation, with the processor configuration serving as the place to organize and order those steps.

The package is at version 13.0.2 under the MIT license, with 1.7M weekly downloads and 2.3K GitHub stars. Its reported unpacked size is 13.3 kB and gzip bundle size is 70.0 kB; account for the bundle figure when deciding whether to include it in a client-side build, especially if the processing can instead run in a server or build pipeline.

rehype’s core is an HTML processing framework, not a complete solution for every HTML task: the capabilities of a pipeline depend on its configured plugins. Teams should check that the plugins they need support the desired transformations and account for plugin ordering, since each step can affect the tree passed to later steps.

WHEN TO USE
  • When transforming HTML structurally, configure a unified processor and add plugins with `.use()` instead of relying on string replacements.
  • When building repeatable HTML-processing steps, keep parsing, tree transformations, and output in a single processor pipeline.
  • When integrating HTML handling with other unified collective tools, use rehype as the HTML-processing part of the workflow.
  • When plugin behavior needs to be explicit, configure the required plugins and their order on the processor.
  • When processing content in a build or server workflow, use a configured rehype pipeline to produce transformed HTML before delivery.
  • When validating or inspecting HTML through tree-based transformations, select plugins that implement the checks or edits your pipeline requires.
WHEN NOT TO USE
  • If the task is limited to a direct text replacement in an HTML string, use a targeted string operation rather than configuring a syntax-tree processing pipeline.
  • If the required transformation is not available in the plugins you can use, choose a tool that directly provides that operation or implement the transformation separately.
  • If you need a complete HTML rendering framework rather than an HTML processor, use a framework designed to render application interfaces; rehype focuses on processing HTML.
  • If the processing must run in a client bundle and the reported 70.0 kB gzip bundle size is unsuitable, move the pipeline to a build or server step where possible.
  • If your workflow cannot accommodate plugin configuration and ordering, use a more direct HTML-processing approach with fewer pipeline setup requirements.

CORRECTIONS

Spot wrong data here?

A short note helps us fix it.

Anonymous · No account · No email back

COMPARISONS 5
rehype vs @mdx-js/react ★ 19.9K · 33.3M/wk rehype vs shiki ★ 14.0K · 42.0M/wk rehype vs mdast-util-mdx-jsx ★ 35 · 70.0M/wk rehype vs remark ★ 9.0K · 11.0M/wk rehype vs marked ★ 37.3K · 135.3M/wk