# htmlencode

> Wrapped version of http://www.strictly-software.com/htmlencode

Latest version **0.0.5** (published 2026-03-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install htmlencode
pnpm add htmlencode
yarn add htmlencode
bun add htmlencode
```

## Health

**Score 45/100 (D)** — status: stable.

Positive: no vulnerabilities.

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

## Facts

| | |
|---|---|
| Version | 0.0.5 |
| Published | 2026-03-04 |
| First published | 2013-01-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 18 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 10 |
| Author | Dan MacTough |
| Maintainers | danmactough |
| Keywords | html, encode, decode |

## Links

- npm: https://www.npmjs.com/package/htmlencode
- Repository: https://github.com/danmactough/node-htmlencode
- Issues: https://github.com/danmactough/node-htmlencode/issues
- npm.io page: https://npm.io/package/htmlencode

## Alternatives

- [@tsparticles/shape-image](https://npm.io/package/@tsparticles/shape-image.md) — 303.7K weekly downloads
- [@tsparticles/shape-line](https://npm.io/package/@tsparticles/shape-line.md) — 233.7K weekly downloads
- [stringify-attributes](https://npm.io/package/stringify-attributes.md) — 58.6K weekly downloads
- [mobile-drag-drop](https://npm.io/package/mobile-drag-drop.md) — 46.3K weekly downloads
- [@comunica/actor-rdf-parse-html](https://npm.io/package/@comunica/actor-rdf-parse-html.md) — 29.2K weekly downloads

## Recent versions

- 0.0.5 (latest) — 2026-03-04
- 0.0.4 — 2014-05-30
- 0.0.3 — 2013-01-21

## README

# node-htmlencode

A wrapped version of http://www.strictly-software.com/htmlencode library --
only two changes to the original:

1. Renamed global `Encoder` object to `module.exports` so it can be used as a Node module.
2. Fixed leaking global variable `arr` in `htmlDecode` method

## Usage

In addition to the very minor changes described above, the library is wrapped in
a function to allow you to `require` just the individual method(s) you want.

```js
var htmlencode = require('htmlencode');
htmlencode.htmlEncode('<h1>Welcome</h1>');
// &lt;h1&gt;Welcome&lt;/h1&gt;
```

works the same as

```js
var htmlEncode = require('htmlencode').htmlEncode;
htmlEncode('<h1>Welcome</h1>');
// &lt;h1&gt;Welcome&lt;/h1&gt;
```

If you want to change to using numeric HTML entities, you'll still want to do
something like this:

```js
var htmlencode = require('htmlencode');
htmlencode.EncodeType = 'numerical'; // Don't blame me. I didn't name it.
htmlencode.htmlEncode('<h1>Welcome</h1>');
// &#60;h1&#62;Welcome&#60;/h1&#62;
```

Also provided is `module.exports.Encoder`, the wrapper class, so you can do
something like this if you so choose:

```js
var htmlencode = require('htmlencode');
var widget = new htmlencode.Encoder('numerical');
widget.htmlEncode('<h1>Welcome</h1>');
// &#60;h1&#62;Welcome&#60;/h1&#62;
```

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