html-react-parser

Converts HTML strings into React elements, working seamlessly on both server and client

Library
npm
v6.1.7
2,424stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
87/100Excellent
Development Activity96
Maintenance96
Community56
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
83/100Excellent
Architecture82
Code Quality88
Innovation78
Learning Curve85

html-react-parser is a lightweight TypeScript library that converts raw HTML strings into React elements at runtime. It runs identically in Node.js (SSR) and in the browser, making it useful anywhere HTML content needs to be rendered as native React nodes rather than injected via dangerouslySetInnerHTML.

The library exposes a single default-export function alongside a replace option for swapping specific DOM elements with custom React components, and a transform option for per-node transformation during traversal. It builds on html-dom-parser (a wrapper around htmlparser2) for parsing and style-to-js for inline style conversion, keeping the dependency surface small while supporting custom parsing engines.

What You Get

  • A single parse(html, options) function that returns React elements, an array of elements, or a string
  • A replace option to swap matched DOM nodes with custom React components or remove them
  • A transform option for per-node transformation during the HTML-to-React walk
  • Works identically during server-side rendering and in the browser
  • TypeScript types shipped in the package, plus CJS, ESM, and UMD builds

Common Use Cases

  • Rendering HTML fetched from a headless CMS as native React elements instead of raw innerHTML
  • Replacing specific tags (e.g. <a>, <img>) with custom React components while parsing rich content
  • Server-rendering HTML fragments in a Next.js or other SSR app without a client-only DOM dependency
  • Post-processing markdown-rendered HTML to inject interactive React components

Under The Hood

Architecture The library is a thin three-stage pipeline: html-dom-parser (an htmlparser2 wrapper) parses the input HTML string into a DOM node tree, dom-to-react.ts recursively walks that tree converting each DOMNode into React.createElement calls (handling replace/transform hooks per node), and attributes-to-props.ts maps HTML attributes/inline styles to React props (via style-to-js and react-property for attribute-name mapping). The public surface is a single default export (src/index.ts, 40 lines) that wires these stages together, keeping the whole conversion synchronous and dependency-light.

Tech Stack Written in TypeScript, built with tsc for CJS and Rollup for a UMD bundle, targeting both CJS and ESM consumers via package.json exports. Runtime dependencies are minimal and pinned exactly: domhandler, html-dom-parser, react-property, style-to-js. Tests run on Vitest (including a browser mode via Playwright for real-DOM verification), linting via ESLint 10 with typescript-eslint, and releases are automated with conventional commits and changelog generation.

Code Quality The __tests__ directory mirrors src/ one-to-one (dom-to-react, attributes-to-props, utilities.test.ts, plus an integration/ suite and browser-mode tests), and CI runs both Node and browser test targets plus arethetypeswrong and publint to verify package exports are correct. Source files are small and single-purpose (40-182 lines each), fully typed with exported HTMLReactParserOptions, and the entry point throws a TypeError on non-string input rather than failing silently.

API Design The API is a single default function with an optional second options argument, so the zero-config path (parse(html)) requires no setup. Power users get two well-documented escape hatches (replace, transform) without needing to learn a plugin system, and the package re-exports the underlying DOM node types (Comment, Element, Text) so consumers can type-narrow inside replace callbacks. The extensive README with a table of contents, FAQ, and migration guides for five major versions materially lowers the learning curve.

Used by 8 apps in this directory

TypeScript
72%
AGPL 3.0

APITable

Low Code Platforms · Databases

15,526

API-first collaborative spreadsheet-database platform that auto-generates REST APIs and lets teams build internal tools, CRMs, and dashboards without code.

View details
53
Repo Health
77
Technical
60
Dependency
Built with
TypeScript72%
Java22%
Updated 9 months ago
TypeScript
99%
Other

byterover-cli

AI Agents · AI Code Assistants

4,941

A portable memory layer for AI coding agents — curate structured project knowledge into a version-controlled context tree that syncs across tools, machines, and teammates.

View details
77
Repo Health
83
Technical
71
Dependency
Built with
TypeScript99%
Updated 1 months ago
TypeScript
94%
AGPL 3.0

Element Web

Team Chat · Collaboration

13,387

A polished, self-hostable Matrix client for secure, decentralized messaging and collaboration that puts your organization in full control of its data.

View details
96
Repo Health
83
Technical
67
Dependency
Built with
TypeScript94%
Updated today
TypeScript
62%
Other

Flowise

Developer Tools · Automation · No Code Platforms

55,379

Drag-and-drop visual builder for AI agents, RAG pipelines, and multi-agent systems—deploy anywhere in minutes.

View details
91
Repo Health
77
Technical
64
Dependency
Built with
TypeScript62%
JavaScript27%
Updated 6 days ago
TypeScript
38%
Apache 2.0

Label Studio

AI Development · Data Engineering

28,083

Label Studio is an open-source, multi-type data labeling platform that lets teams annotate images, text, audio, video, and time series data with a configurable XML-based UI and export annotations in formats ready for any ML framework.

View details
93
Repo Health
87
Technical
68
Dependency
Built with
TypeScript38%
JavaScript27%
Python25%
Updated today
JavaScript
44%
Other

LimeSurvey

Forms Surveys

3,698

The world's most flexible open-source survey platform with 900+ templates, conditional logic, 80+ languages, and full GDPR compliance for any scale.

View details
86
Repo Health
62
Technical
62
Dependency
Built with
JavaScript44%
PHP34%
CSS12%
Updated today
Python
61%
Apache 2.0

marimo

Developer Tools · Data Engineering

22,393

A reactive Python notebook that eliminates hidden state, runs reproducibly, and deploys as a web app or script — stored as pure Python, built for the AI era.

View details
90
Repo Health
91
Technical
66
Dependency
Built with
Python61%
TypeScript37%
Updated today
HTML
32%

OpenPanel

Hosting Control Panel · Devops

733

Docker-powered web hosting control panel that gives every user a fully isolated environment with dedicated web server, database, and networking — VPS-grade security on shared hardware.

View details
81
Repo Health
75
Technical
63
Dependency
Built with
HTML32%
Go31%
TypeScript28%
Updated today

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search