Html React Parser screenshot

Html React Parser

Author Avatar Theme by Remarkablemark
Updated: 22 May 2025
2283 Stars

HTML to React parser.

Overview:

html-react-parser is a versatile HTML to React parser that can be used on both server-side (Node.js) and client-side (browser) applications. It allows for the conversion of HTML strings into one or more React elements, along with additional features such as element replacement, transforming elements, and handling element attributes.

Features:

  • HTML to React Parsing: Convert HTML strings to React elements.
  • Element Replacement: Ability to replace one element with another.
  • Transform Elements: Transform each parsed element individually.
  • Element Attributes Handling: Replace, remove, or convert element attributes.
  • Support for Multiple Libraries: Default support for React with options for Preact or custom libraries.
  • Whitespace Trimming: Control over preservation or removal of whitespace.
  • Ongoing Development: Regular updates and migration to TypeScript for improved functionality.

Installation:

  1. NPM Installation:
    npm install html-react-parser
    
  2. Yarn Installation:
    yarn add html-react-parser
    
  3. CDN: Add the CDN link to your HTML file:
    <script src="https://cdn.jsdelivr.net/npm/html-react-parser"></script>
    

Summary:

html-react-parser is a feature-rich HTML to React parsing tool that caters to both server and client-side applications. With capabilities like element replacement, attribute handling, and support for different libraries, it offers flexibility and ease of use for developers. The ongoing development and migration to TypeScript ensure that the tool remains up-to-date and efficient for various projects.