# html-parse-string

> Utils for parsing and stringify html strings

Latest version **0.0.9** (published 2023-04-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install html-parse-string
pnpm add html-parse-string
yarn add html-parse-string
bun add html-parse-string
```

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.9 |
| Published | 2023-04-04 |
| First published | 2018-03-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 15.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 16 |
| Author | Ryan Carniato |
| Maintainers | ryansolid |

## Links

- npm: https://www.npmjs.com/package/html-parse-string
- Repository: https://github.com/ryansolid/html-string-parser
- Homepage: https://github.com/ryansolid/html-string-parser#readme
- Issues: https://github.com/ryansolid/html-string-parser/issues
- npm.io page: https://npm.io/package/html-parse-string

## Recent versions

- 0.0.9 (latest) — 2023-04-04
- 0.0.8 — 2022-07-09
- 0.0.7 — 2022-07-07
- 0.0.6 — 2021-01-04
- 0.0.5 — 2019-04-23
- 0.0.4 — 2019-04-23
- 0.0.3 — 2019-04-13
- 0.0.2 — 2018-03-15
- 0.0.1 — 2018-03-15

## README

# html-parse-string
HTML parse and stringify utils

## Installation

```
npm install html-parse-string
```

## IDom
basic data structure
```
export interface IDom {
  type: string;
  content ? : string;
  voidElement: boolean;
  name: string;
  attrs: { [key: string]: any };
  children: IDom[];
}

```

## parse
parse html to idom array
```
const { parse, stringify } = require('html-parse-string');
const t = `<div>this is div</div>`;
console.log(parse(t));
```
get idom array
```
[
  {
    type: "tag",
    name: "div",
    voidElement: false,
    attrs: {},
    children: [
      {
        type: "text",
        content: "this is div",
      },
    ],
  },
];
```
## stringify
stringify idom array to html
```
const { parse, stringify } = require('html-parse-string');
const t = `<div>this is div</div>`;
const ast = parse(t);
console.log(stringify(ast));
```
get html string
```
<div>this is div</div>
```

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