Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

243
Views
Parse html tags from a JSON file in ReactJs

In a ReactJs application, fetching data from a Json file which contains some HTML tags, which is displayed as string without interpreting it as HTML.

I considered to use dangerouslySetInnterHTML. However, according to React's official documentation, setting HTML from code seems to be risky.

Any other best practice to achieve the same.

Sample Json:

{
  "FAQ" : {
             "contents": "Lorem ipsum dolor sit amet. <a href=\"www.test.com\">www.test.com</a>",
          }
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

To parse html tags in a Json content in a React application there is a npm package available name 'html-to-react'

Usage:

import React from 'react';
import convertHtmlToReact from '@hedgedoc/html-to-react';

class HtmlComponent extends React.Component {
  render() {
    const html = '<div>Example HTML string</div>';
    return <div>{ convertHtmlToReact (html, true) }</div>;
  }
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!