ent (2.2.2)

Published 2026-02-24 13:55:55 +00:00 by atheaadmin

Installation

registry=
npm install ent@2.2.2
"ent": "2.2.2"

About this package

ent Version Badge

github actions coverage License Downloads

npm badge

Encode and decode HTML entities

example

var ent = require('ent');
console.log(ent.encode('<span>©moo</span>'))
console.log(ent.decode('&pi; &amp; &rho;'));
&#60;span&#62;&#169;moo&#60;/span&#62;
π & ρ

ent

methods

var ent = require('ent');
var encode = require('ent/encode');
var decode = require('ent/decode');

encode(str, opts={})

Escape unsafe characters in str with html entities.

By default, entities are encoded with numeric decimal codes.

If opts.numeric is false or opts.named is true, encoding will used named codes like &pi;.

If opts.special is set to an Object, the key names will be forced to be encoded (defaults to forcing: <>'"&). For example:

console.log(encode('hello', { special: { l: true } }));
he&#108;&#108;o

decode(str)

Convert html entities in str back to raw text.

credits

HTML entity tables are from the official entities.json file for the whatwg HTML specification.

install

With npm do:

npm install ent

license

MIT

Dependencies

Dependencies

ID Version
call-bound ^1.0.3
es-errors ^1.3.0
punycode ^1.4.1
safe-regex-test ^1.1.0

Development Dependencies

ID Version
@ljharb/eslint-config ^21.1.1
auto-changelog ^2.5.0
encoding ^0.1.13
eslint =8.8.0
evalmd ^0.0.19
in-publish ^2.0.1
npmignore ^0.3.1
nyc ^10.3.2
safe-publish-latest ^2.0.0
tape ^5.9.0

Keywords

entities entitify entity html encode decode
Details
npm
2026-02-24 13:55:55 +00:00
0
James Halliday
MIT
latest
29 KiB
Assets (1)
ent-2.2.2.tgz 29 KiB
Versions (1) View all
2.2.2 2026-02-24