# html-encode

> Convert HTML documents of arbitrary encoding into a target charset such as UTF-8 or UTF-16.

Latest version **2.1.20** (published 2026-10-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install html-encode
pnpm add html-encode
yarn add html-encode
bun add html-encode
```

## Health

**Score 55/100 (C)** — status: active.

Positive: no vulnerabilities; recently updated; high maintenance score.

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

## Facts

| | |
|---|---|
| Version | 2.1.20 |
| Published | 2026-10-29 |
| First published | 2017-11-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 20 |
| Dependencies | 4 |
| Unpacked size | 6.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Kiko Beats |
| Maintainers | kikobeats |
| Keywords | charset, decode, document, encode, encoding, html, iconv, transcode, utf16, utf8 |

## Links

- npm: https://www.npmjs.com/package/html-encode
- Repository: https://github.com/kikobeats/html-encode
- Homepage: https://github.com/Kikobeats/html-encode
- Issues: https://github.com/kikobeats/html-encode/issues
- npm.io page: https://npm.io/package/html-encode

## Dependencies (4)

- [charset](https://npm.io/package/charset.md) ~1.0.1
- [is-buffer](https://npm.io/package/is-buffer.md) ~2.0.5
- [jschardet](https://npm.io/package/jschardet.md) ~4.1.0
- [iconv-lite](https://npm.io/package/iconv-lite.md) ~0.7.0

## Alternatives

- [flatbuffers](https://npm.io/package/flatbuffers.md) — 6.0M weekly downloads
- [@exodus/patch-broken-hermes-typed-arrays](https://npm.io/package/@exodus/patch-broken-hermes-typed-arrays.md) — 28.5K weekly downloads
- [@native-to-anchor/buffer-layout](https://npm.io/package/@native-to-anchor/buffer-layout.md) — 12.2K weekly downloads
- [binary-parser-encoder](https://npm.io/package/binary-parser-encoder.md) — 5.3K weekly downloads
- [datasets-fi-postalcodes](https://npm.io/package/datasets-fi-postalcodes.md) — 1.1K weekly downloads

## Recent versions

- 2.1.20 (latest) — 2026-10-29
- 2.1.19 — 2026-10-28
- 2.1.18 — 2026-10-14
- 2.1.17 — 2026-10-01
- 2.1.16 — 2026-09-30
- 2.1.15 — 2026-04-14
- 2.1.14 — 2026-03-18
- 2.1.13 — 2025-11-21
- 2.1.12 — 2025-10-15
- 2.1.11 — 2025-09-05
- 2.1.10 — 2025-08-21
- 2.1.9 — 2025-08-12
- 2.1.8 — 2025-03-03
- 2.1.7 — 2024-05-08
- 2.1.6 — 2021-04-16
- … 7 more at https://npm.io/package/html-encode/versions

## README

# html-encode

[![Last version](https://img.shields.io/github/v/tag/Kikobeats/html-encode?style=flat-square)](https://github.com/Kikobeats/html-encode/releases)
[![Coverage Status](https://img.shields.io/coverallsCoverage/github/Kikobeats/html-encode?style=flat-square)](https://coveralls.io/github/Kikobeats/html-encode)
[![NPM Status](https://img.shields.io/npm/dm/html-encode?style=flat-square)](https://www.npmjs.com/package/html-encode)

> A Node.js library for converting HTML documents of arbitrary encoding into a target encoding (utf8, utf16, etc).

### Install

```bash
$ npm install html-encode
```

### Usage

```js
'use strict'

const contentType = require('@kikobeats/content-type')
const got = require('got')

const toUTF8 = require('html-encode')('utf-8')
const url = process.argv[2]

;(async () => {
  const { body: buffer, headers } = await got(url, { responseType: 'buffer' })
  const str = toUTF8(buffer, contentType(headers['content-type']))
  console.log(str)
})()
```

See more at [examples](/examples).

## License

**html-encode** © [Kiko Beats](https://kikobeats.com), released under the [MIT](https://github.com/Kikobeats/html-encode/blob/master/LICENSE.md) License.<br>
Authored and maintained by Kiko Beats with help from [contributors](https://github.com/Kikobeats/html-encode/contributors).

> [kikobeats.com](https://kikobeats.com) · GitHub [Kiko Beats](https://github.com/Kikobeats) · X [@Kikobeats](https://x.com/Kikobeats)

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