# html-to-object

> A parser for JavaScript that converts native HTML to the equivalent JavaScript element.

Latest version **1.3.7** (published 2017-07-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install html-to-object
pnpm add html-to-object
yarn add html-to-object
bun add html-to-object
```

## 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 | 1.3.7 |
| Published | 2017-07-27 |
| First published | 2017-06-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Max Sandelin |
| Maintainers | themaxsandelin |
| Keywords | html parser, javascript parser, parser, html, object, javascript, js |

## Links

- npm: https://www.npmjs.com/package/html-to-object
- Repository: https://github.com/themaxsandelin/html-to-object
- Homepage: https://github.com/themaxsandelin/html-to-object#readme
- Issues: https://github.com/themaxsandelin/html-to-object/issues
- npm.io page: https://npm.io/package/html-to-object

## Dependencies (1)

- [jsdom](https://npm.io/package/jsdom.md) ^11.0.0

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.3.7 (latest) — 2017-07-27
- 1.3.6 — 2017-07-27
- 1.3.5 — 2017-07-27
- 1.3.3 — 2017-07-27
- 1.3.2 — 2017-07-27
- 1.3.1 — 2017-06-30
- 1.3.0 — 2017-06-30
- 1.2.1 — 2017-06-21
- 1.2.0 — 2017-06-21
- 1.1.2 — 2017-06-18
- 1.1.1 — 2017-06-17
- 1.1.0 — 2017-06-16
- 1.0.5 — 2017-06-15
- 1.0.4 — 2017-06-15
- 1.0.3 — 2017-06-14
- … 3 more at https://npm.io/package/html-to-object/versions

## README

# html-to-object
A lightweight HTML parser for JavaScript that converts your native HTML code into an Array of JavaScript Objects.

## Install
`$ npm install --save html-to-object`

## Usage
```javascript
const h2o = require('html-to-object');

const results = h2o('path/to/file.html', [options]);
```

## Options

#### build (default: false)
Returns the parsed elements as prebuilt DOM nodes to easily append them to the page.
```javascript
const fs = require('fs');
const h2o = require('html-to-object');

const results = h2o('path/to/file.html', { build: true });
```

#### targetIsFile (default: true)
In case of preloaded .html file content.
```javascript
const fs = require('fs');
const h2o = require('html-to-object');

const html = fs.readFileSync('path/to/file.html', 'utf8');
const results = h2o(html, { targetIsFile: false });
```

#### attributesAsObject (default: false)
Will define the attributes property of each element as an Object instead of an Array.
```javascript
const h2o = require('html-to-object');

const results = h2o('path/to/file.html', { attributesAsObject: true });
```


## License
[MIT](LICENSE) © [Max Sandelin](https://github.com/themaxsandelin)

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