/react-html-parser

Converts HTML string directly into React components avoiding the need to use dangerouslySetInnerHTML

Primary LanguageJavaScriptMIT LicenseMIT

React HTML Parser

A utility for converting HTML strings into React components. Avoids the use of dangerouslySetInnerHTML and converts standard HTML elements, attributes and inline styles into their React equivalents.

Try the Live Demo

Travis branch Coveralls npm David

Install

npm install react-html-parser

Usage

import React from 'react';
import ReactHtmlParser from 'react-html-parser';

class HtmlComponent extends React.Component {
  render() {
    const html = '<div>Example HTML string</div>';
    return <div>{ ReactHtmlParser(html) }</div>;
  }
}