🌐
GitHub
github.com › remarkablemark › html-react-parser
GitHub - remarkablemark/html-react-parser: 📝 HTML to React parser.
html-dom-parser has been upgraded to v7 and domhandler has been upgraded to v6. Migrated to TypeScript. CommonJS imports require the .default key: const parse = require('html-react-parser').default;
Starred by 2.4K users
Forked by 140 users
Languages   TypeScript 87.9% | JavaScript 12.1%
🌐
GitHub
github.com › remarkablemark › html-react-parser › blob › master › examples › create-react-app-typescript › src › App.tsx
html-react-parser/examples/create-react-app-typescript/src/App.tsx at master · remarkablemark/html-react-parser
import parse, { domToReact, htmlToDOM, Element } from 'html-react-parser'; import './App.css'; · console.log(domToReact); console.log(htmlToDOM); · export default function App() { return ( <div className="App"> {parse( ` <h1 style="font-family: 'Lucida Grande';"> HTMLReactParser<br class="remove"> with Create React App (TypeScript) </h1> `, { replace(domNode) { if ( domNode instanceof Element && domNode.attribs.class === 'remove' ) { return <></>; } }, } )} </div> ); }
Author   remarkablemark
🌐
GitHub
github.com › peternewnham › react-html-parser
GitHub - peternewnham/react-html-parser: Converts HTML strings directly into React components and provide a simple way to modify and replace the content. · GitHub
Converts HTML strings directly into React components and provide a simple way to modify and replace the content. - peternewnham/react-html-parser
Starred by 797 users
Forked by 103 users
Languages   JavaScript
🌐
GitHub
gist.github.com › natterstefan › 3bc712eca6ff88781d687b7240a78cc1
html-react-parser | TypeScript solution · GitHub
html-react-parser | TypeScript solution. GitHub Gist: instantly share code, notes, and snippets.
🌐
GitHub
github.com › styleguidist › react-docgen-typescript
GitHub - styleguidist/react-docgen-typescript: A simple parser for react properties defined in typescript instead of propTypes. · GitHub
A simple parser for React properties defined in TypeScript instead of propTypes.
Starred by 1.3K users
Forked by 257 users
Languages   TypeScript
🌐
npm
npmjs.com › package › @types › react-html-parser
@types/react-html-parser - npm
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react-html-parser. import { DomElement } from "htmlparser2"; import { ReactElement } from "react"; export interface Transform { // eslint-disable-next-line @typescript-eslint/no-invalid-void-type (node: DomElement, index: number, transform?: Transform): ReactElement | void | null; } export interface Options { decodeEntities?: boolean | undefined; transform?: Transform | undefined; preprocessNodes?(nodes: DomElement[]): any; } export function convertNodeToElement( node: DomElement, index: number, transform: Transform, ): ReactElement; export function processNodes(nodes: DomElement[], transform: Transform): ReactElement[]; export default function HtmlParser(html: string, options?: Options): ReactElement[]; Last updated: Mon, 03 Mar 2025 19:02:28 GMT ·
      » npm install @types/react-html-parser
    
🌐
GitHub
github.com › wrakky › react-html-parser › issues › 54
Does this support typescript? · Issue #54 · peternewnham/react-html-parser
December 2, 2018 - Try npm install @types/react-html-parser if it exists or add a new declaration (.d.ts) file containing declare module 'react-html-parser';
Author   paigeflourin
🌐
JSFiddle
jsfiddle.net › remarkablemark › 7v86d800
html-react-parser example - JSFiddle - Code Playground
Adding External Resources will no longer create a list of resources in the sidebar but will be injected as a LINK or SCRIPT tag inside of the HTML panel.
🌐
GitHub
github.com › remarkablemark › html-react-parser › blob › master › package.json
html-react-parser/package.json at master · remarkablemark/html-react-parser
April 12, 2024 - "html-dom-parser": "5.0.13", "react-property": "2.0.2", "style-to-js": "1.1.16" }, "devDependencies": { "@commitlint/cli": "19.8.0", "@commitlint/config-conventional": "19.8.0", "@eslint/compat": "1.2.7", "@eslint/eslintrc": "3.3.0", "@eslint/js": "9.22.0", "@rollup/plugin-commonjs": "28.0.3", "@rollup/plugin-node-resolve": "16.0.1", "@rollup/plugin-terser": "0.4.4", "@rollup/plugin-typescript": "12.1.2", "@size-limit/preset-big-lib": "11.2.0", "@types/benchmark": "2.1.5", "@types/jest": "29.5.14", "@types/node": "22.13.10", "
Author   remarkablemark
Find elsewhere
🌐
npm
npmjs.com › package › html-react-parser
html-react-parser - npm
1 month ago - html-dom-parser has been upgraded to v7 and domhandler has been upgraded to v6. Migrated to TypeScript. CommonJS imports require the .default key: const parse = require('html-react-parser').default;
      » npm install html-react-parser
    
Published   Apr 08, 2026
Version   6.0.1
🌐
GitHub
github.com › topics › html-react-parser
html-react-parser · GitHub Topics · GitHub
queries html-react-parser tailwindcss loading-effcts programmable-search-engine nextjs14 ... Practice repository, to use Zustand and MSW. react typescript jest reactjs html-react-parser github-jobs testing-library msw zustand
Top answer
1 of 7
57

You probably want to look deeper into dangerouslySetInnerHTML. Here is an example how to render HTML from a string in a React component:

import React from 'react';
import { render } from 'react-dom';

const htmlString = '<h1>Hello World! </h1>';

const App = () => (
  <div dangerouslySetInnerHTML={{ __html: htmlString }} />
);

render(<App />, document.getElementById('root'));

Full example here: https://codesandbox.io/s/xv40xXQzE

Read more about dangerouslySetInnerHTML in the React docs here: https://facebook.github.io/react/docs/dom-elements.html#dangerouslysetinnerhtml

2 of 7
30

As pointed out in this answer by EsterlingAccimeYoutuber, you can use a parser in case you don't want to use dangerouslySetInnerHTML attribute.

By now, react-html-parser has not been updated for 3 years, so I went looking for a different module.

html-react-parser does same job but is frequently maintained and updated.

It should be good practice to sanitize your html-String to prevent XSS attacks. dompurify can be used for that.

I updated EsterlingAccimeYoutuber's code-example to the following:

import React from 'react';
import { render } from 'react-dom';
import parse from 'html-react-parser';
import DOMPurify from 'dompurify';

const SpecialButton = ({ children, color }) => (
  <button style={{color}}>{children}</button>
);

const htmlFromCMS = `
<div>Hi, 
  <SpecialButton color="red">My Button</SpecialButton>
</div>`;

const htmlFrom = (htmlString) => {
        const cleanHtmlString = DOMPurify.sanitize(htmlString,
          { USE_PROFILES: { html: true } });
        const html = parse(cleanHtmlString);
        return html;
}

const App = () => (
  <div>
     {htmlFromCMS && htmlFrom(htmlFromCMS)}
  </div>
);


render(<App />, document.getElementById('root'));

Inspired by original post above, hence special thanks to original authors!

🌐
Peternewnham
peternewnham.github.io › react-html-parser
React HTML Parser Demo
We cannot provide a description for this page right now
🌐
GitHub
github.com › topics › react-html-parser
react-html-parser · GitHub Topics · GitHub
November 9, 2018 - nextjs nprogress tailwindcss react-content-loader next-pwa react-html-parser next-sitemap ... In this age of pictures, hashtags, Reels and Tiktoks, likes and comments, a traditional bookworm’s heaven would be a blog to get access to more text-based content. Chatter aims to be that heaven specifically for this kind of audience. A multi-functional platform where authors and readers can create and have access to their own content · react sass typescript react-router scss material-icons tinymce-wysiwyg-editor firebase-auth react-html-parser react-helmet-async firebase-firestore-database formik-yup
🌐
GitHub
github.com › remarkablemark › html-react-parser › blob › master › CHANGELOG.md
html-react-parser/CHANGELOG.md at master · remarkablemark/html-react-parser
deps: bump html-dom-parser from 5.0.3 to 5.0.4 (#1141) (f5d9149) esm: support vite bundler (bad1e4c), closes #1132 · domToReact: refactoring multiple types (8ef6201) dom-to-react: default props.children to undefined instead of null (a6978c3) types: add back object to replace option return type (88eea66) CommonJS imports require the .default key · migrate to TypeScript (713c548), closes #1000 ·
Author   remarkablemark
🌐
GitHub
github.com › topics › react-parser
react-parser · GitHub Topics · GitHub
react javascript html npm parser package library typescript parse dom jsx html-react-parser react-parser
🌐
GitHub
github.com › topics › html-parser
html-parser · GitHub Topics · GitHub
Convert a string containing html tags to an array of React elements. Light and secure ... Convert vanilla HTML to Vue 3 Single File Components instantly. Supports Composition API & Options API with smart parsing of scripts, styles, and templates. Built with Nuxt 3, TypeScript, and fully tested. html open-source converter vuejs opensource typescript vue tool nuxt html-parser ...
🌐
Snyk
snyk.io › advisor › html-react-parser › html-react-parser code examples
Top 5 html-react-parser Code Examples | Snyk
April 19, 2022 - reportportal / service-ui / app / src / pages / inside / dashboardItemPage / modals / common / widgets.jsx View on Github · // description: ( // // ), // preview: Parser(MOST_TIME_CONSUMING_PREVIEW), // controls: MostTimeConsumingTestCasesControls, // }, ]; export const WIDGETS_STATIC_PREVIEWS = { [FLAKY_TEST_CASES_TABLE]: Parser(FLAKY_TEST_CASES_TABLE_PREVIEW), [LAUNCHES_TABLE]: Parser(LAUNCHES_TABLE_PREVIEW), [MOST_FAILED_TEST_CASES_TABLE]: Parser(MOST_FAILED_TEST_CASES_TABLE_PREVIEW), [PROJECT_ACTIVITY]: Parser(PROJECT_ACTIVITY_PREVIEW), [UNIQUE_BUGS_TABLE]: Parser(UNIQUE_BUGS_TABLE_PREVIE
🌐
GitHub
github.com › AlenToma › advanced-html-parser
GitHub - AlenToma/advanced-html-parser: Html parser for web, react-native android, ios, windows and macOS
Can use html parser in react-native, titanium, and anywhere. This is based on xmldom. This library is based on react-native-html-parser where it has much more features and it can decode almost all charecters set, also added support to CSS3 selectors ...
Starred by 6 users
Forked by 3 users
Languages   JavaScript 100.0% | JavaScript 100.0%