# jsx-html-converter

> converts html to valid jsx

Latest version **2.0.3** (published 2023-05-04) · ISC license · 0 weekly downloads

## Install

```sh
npm install jsx-html-converter
pnpm add jsx-html-converter
yarn add jsx-html-converter
bun add jsx-html-converter
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.3 |
| Published | 2023-05-04 |
| First published | 2023-04-29 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 51.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Ralph Tungol |
| Maintainers | tungolra |

## Links

- npm: https://www.npmjs.com/package/jsx-html-converter
- Repository: https://github.com/tungolra/jsx-html-converter
- Homepage: https://github.com/tungolra/jsx-html-converter#readme
- Issues: https://github.com/tungolra/jsx-html-converter/issues
- npm.io page: https://npm.io/package/jsx-html-converter

## Dependencies (1)

- [htmlparser2](https://npm.io/package/htmlparser2.md) ^8.0.2

## Recent versions

- 2.0.3 (latest) — 2023-05-04
- 2.0.2 — 2023-05-04
- 2.0.1 — 2023-05-04
- 2.0.0 — 2023-04-29
- 1.0.0 — 2023-04-29

## README

# jsx-html-converter

This npm package provides a function that can be used to convert an HTML string to valid JSX by closing any optional tags that are valid in HTML. This can be useful when working with HTML content in a React application.

### Installation
You can install this package using npm:

<code>npm i jsx-html-converter</code>

### Usage
To use the closeOptionalTags function, import it into your JavaScript file:

<code>const closeOptionalTags = require("jsx-html-converter");</code>
You can then call the function with an HTML string as the argument:

<code>const html = `<p>Hello, world!</p>`
const jsx = closeOptionalTags(html);
console.log(jsx);</code>
// Output: 
`<p>Hello, world!</p>`

The function will return the HTML string converted to valid JSX, with any optional tags closed:


<code>const html = `<img src='example.jpg'>`;
const jsx = closeOptionalTags(html);
console.log(jsx);</code>
// Output:
 `<img src='example.jpg'/>`

### License
This package is licensed under the MIT license.

### Repo
https://github.com/tungolra/html-jsx-converter

---
_Source: https://npm.io/package/jsx-html-converter · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
