Skip to Content
  • Website
Codsen
  • Home
  • Open Source
  • Articles
  • About

prevOpen Source→all-named-html-entitiesnext

all-named-html-entities3.2.0

List of all named HTML entities

Downloads per monthChangelogMIT Licenselibera manifesto
  • the top
  • Installation
  • Quick Take
  • Examples
  • PURPOSE
  • API — ENTSTARTSWIT…
  • API — DECODE()
  • Changelog

Installation

Quick Take

Examples

  • allNamedEntities
  • Decode a named HTML entity
  • entEndsWith
  • Find entity names by a case-insensitive suffix
  • entStartsWith
  • entStartsWithCaseInsensitive
  • Inspect entity-name metadata
  • Test whether a name is a known entity

Purpose

This package exports a plain object with the following keys:

KeyTypePurpose
allNamedEntities
Type: plain object
allNamedEntitiesplain objectall named HTML entities, key is entity’s name, value is raw decoded entity. 2125 in total.
entStartsWith
Type: plain object
entStartsWithplain objectall named HTML entities, grouped by first character, then by second
entEndsWith
Type: plain object
entEndsWithplain objectall named HTML entities, grouped by last character, then by second-to-last
entStartsWithCaseInsensitive
Type: plain object
entStartsWithCaseInsensitiveplain objectall named HTML entities, grouped by first character, then by second, both case-insensitive
entEndsWithCaseInsensitive
Type: plain object
entEndsWithCaseInsensitiveplain objectall named HTML entities, grouped by last character, then by second-to-last, both case insensitive
brokenNamedEntities
Type: plain object
brokenNamedEntitiesplain objectkey-value pairs of common mistyped named HTML entities and their corrections
uncertain
Type: plain object
uncertainplain objectall named HTML entities which could be interpreted as words if entity was malformed (missing ampersand for example)
allNamedEntitiesSetOnly
Type: Set
allNamedEntitiesSetOnlySetSet of all named entities, think of array of strings, only unique and faster. Case sensitive list.
allNamedEntitiesSetOnlyCaseInsensitive
Type: Set
allNamedEntitiesSetOnlyCaseInsensitiveSetSet of all named entities, think of array of strings, only unique and faster. Case in-sensitive list.
decode
Type: function
decodefunctiondecodes named HTML entities (&...; format)
minLength
Type: integer
minLengthintegerlength of the shortest of all named HTML entities (currently 2)
maxLength
Type: integer
maxLengthintegerlength of the longest of all named HTML entities (currently 31)
version
Type: string
versionstringas per package.json, for example, 1.4.0

API — entStartsWith

entStartsWith is a plain object:

{
"A": {
    "E": [
        "AElig"
    ],
    "M": [
        "AMP"
    ],
    "a": [
        "Aacute"
    ],
    ...

The point of entStartsWith is that you don’t have to iterate through up to 2,127 entities to match. Instead, you match by first and second letter and match against that list, which varies but is on average tens of strings long.

Let’s tap it.

For example, imagine you have to check, is there a named HTML entity to the right of string index 2 in string 123Aacute456:

import { entStartsWith } from "all-named-html-entities";

// is there a named HTML entity to the right of index 2?
const input = "123Aacute456";

// first, slice the string from third index onwards; you get "Aacute456"
const workingSlice = input.slice(3);

// this is very verbose and exaggerated code but it's for illustrative purposes

// in real life it would be shorter than all this

// define default answer, false:
let result = false;

if (workingSlice && entStartsWith.hasOwnProperty(workingSlice[0]) && entStartsWith[workingSlice[0]].hasOwnProperty(workingSlice[1]) && entStartsWith[workingSlice[0]][workingSlice[1]].some((entity) => workingSlice.startsWith(entity))) {
  result = true;
}
console.log(`result: ${result}`);
import { all } from "all-named-html-entities";
console.log(Array.isArray(all));

API — decode()

import { decode } from "all-named-html-entities";
console.log(decode("ℵ"));
// => ℵ

If the given input is not a string, or is an empty string or does not start with ampersand or does not end with semicolon, error is thrown.

Else, check is performed and if it’s not found among known entities, a null is returned.

Changelog

Open Changelog
↑ back to top
prev next

Copyright

All rights reserved © Roy Revelt 2026
All our open source packages are under MIT licenceopens in a new tab

Activities

🐛 See a bug? Raise an issueopens in a new tab
💘 Check out the Indiewebopens in a new tab and Libera manifestoopens in a new tab