{"id":25735,"library":"html-to-jsx","title":"html-to-jsx","description":"html-to-jsx is a lightweight, regex-based compiler that converts HTML strings into JSX syntax suitable for React applications. Version 0.0.4 is the latest stable release, though the package has seen no updates since its initial publication, indicating maintenance is stagnant. It differentiates from alternatives like html-react-parser by operating purely with regex without DOM parsing, making it fast but potentially brittle for complex or malformed HTML. The package is minimal, offering no TypeScript types, and is intended for simple conversion tasks where full HTML spec compliance is not required.","status":"maintenance","version":"0.0.4","language":"javascript","source_language":"en","source_url":"git://github.com/littlehaker/html-to-jsx","tags":["javascript","React","JSX"],"install":[{"cmd":"npm install html-to-jsx","lang":"bash","label":"npm"},{"cmd":"yarn add html-to-jsx","lang":"bash","label":"yarn"},{"cmd":"pnpm add html-to-jsx","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The package is ESM-compatible but the default export is a function that expects a string input.","wrong":"const htmlToJsx = require('html-to-jsx')","symbol":"default","correct":"import htmlToJsx from 'html-to-jsx'"},{"note":"In CommonJS environments, the export is an object with a single method; named ESM import is incorrect.","wrong":"import { htmlToJsx } from 'html-to-jsx'","symbol":"htmlToJsx","correct":"const { htmlToJsx } = require('html-to-jsx')"},{"note":"The package does not ship TypeScript definitions or type exports.","wrong":"import type { Options } from 'html-to-jsx'","symbol":"type import","correct":"// No type exports available"}],"quickstart":{"code":"import htmlToJsx from 'html-to-jsx';\n\nconst html = '<div class=\"container\"><p>Hello World</p></div>';\nconst jsx = htmlToJsx(html);\nconsole.log(jsx);\n// Expected output: <div className='container'><p>Hello World</p></div>","lang":"javascript","description":"Converts a simple HTML string with class attribute to JSX className syntax."},"warnings":[{"fix":"Use a proper HTML parser-based library (e.g., html-react-parser) for reliable conversion of complex HTML.","message":"Regex-based parsing: does not handle nested or complex HTML structures correctly.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Manually verify converted JSX for self-closing tags, or add trailing slashes in input HTML.","message":"Self-closing tags conversion: may not convert all self-closing tags (e.g., <br>, <img>) correctly in all contexts.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Consider migrating to actively maintained alternatives like html-react-parser or dangerouslySetInnerHTML.","message":"Package is unmaintained; no updates since 2015.","severity":"deprecated","affected_versions":">=0.0.0"},{"fix":"Preprocess HTML to remove/replace unsupported features before conversion, or use a more comprehensive tool.","message":"Does not digest features like inline events, React Fragments, or JSX expressions.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run `npm install html-to-jsx` or add it to package.json.","cause":"Package not installed or missing from dependencies.","error":"Cannot find module 'html-to-jsx'"},{"fix":"Use default import: `import htmlToJsx from 'html-to-jsx'` or CommonJS: `const htmlToJsx = require('html-to-jsx').htmlToJsx`.","cause":"Incorrect import of the module (e.g., using named import when default export is expected).","error":"TypeError: htmlToJsx is not a function"},{"fix":"Use `const { htmlToJsx } = require('html-to-jsx')` in CommonJS or `import { htmlToJsx } from 'html-to-jsx'` (if supported).","cause":"Import returned an object with a method named htmlToJsx instead of a function.","error":"htmlToJsx(...) is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}