All HTML entities which are not email template friendly

Quick Take

import { strict as assert } from "assert";
import {
} from "html-entities-not-email-friendly";

// it's object, mapping entity names to numeric equivalents

// it's a Set, only listing the bad entity names
assert.equal(notEmailFriendlySetOnly.size, 1841);

// is ≳ email-friendly?
// no, use numeric entity

// is   email-friendly?
// yes, it's OK


Unlike Web pages, Email templates are sent over SMTP and need to be HTML-encoded.

HTML encoding can be done three ways: decimal (£), hexadecimal (£) and named forms (£).

The named entities can be memorised or recognised more easily than numeric-ones. When we check the template's text, £ is more informative than £. If somebody mistakenly put ¤ you would not tell easily, but &pund; stands out instantly!

The only problem is, not all named entities are supported well across all email clients, in particular, in Windows desktop Outlooks.

This package tells which entities exactly and not supported widely and tells you what to convert them to.

This program exports few different lists:

  • notEmailFriendly — a plain object, key value pairs are like AMP: "amp" — total keys: 1841
  • notEmailFriendlySetOnly — a Set opens in a new tab of only entity names (in correct letter case) — total size: 1841
  • notEmailFriendlyLowercaseSetOnly — an alphabetically sorted Set opens in a new tab of lowercase entity names — total size: 1534


This package exports a plain object with five keys:

  • notEmailFriendly
  • notEmailFriendlySetOnly
  • notEmailFriendlyLowercaseSetOnly
  • notEmailFriendlyMinLength
  • notEmailFriendlyMaxLength
Key's name Key's value's type Purpose
notEmailFriendly plain object Plain object of all named HTML entities. The key is an entity's name; value is a raw decoded entity. 1841 in total.
notEmailFriendlySetOnly set A set of all entity names, in correct case, unsorted. 1841 in total.
notEmailFriendlyLowercaseSetOnly set A set of all entity names, in lowercase, sorted. 1534 in total (because we have AMP and amp for example).
notEmailFriendlyMinLength natural number the string length of the shortest of all entities, currently hardcoded to 2
notEmailFriendlyMaxLength natural number the string length of the longest of all entities, currently hardcoded to 31


const { notEmailFriendly } = require("html-entities-not-email-friendly");
// it's a plain object of key-value pairs where key is entity name, value is
// decoded numeric entity analogue of it
// => 1841

The point of plain object notEmailFriendly is to decode the entities.

For example, among the keys you can see:

And: "#x2A53",

This means, named HTML entity ⩓ is not email friendly and should be put as ⩓.

As you noticed, ampersands and semicolons are missing in keys and values (but they're obligatory in HTML code so add them yourself).


Sets opens in a new tab are awesome because they're fast.

When you import notEmailFriendlySetOnly, it's a Set of only the key names:

const { notEmailFriendlySetOnly } = require("html-entities-not-email-friendly");
for (const entitysName of notEmailFriendlySetOnly) {
// => "AMP",
// "Abreve",
// ...

// another example: check is given entity a valid HTML named entity string?
// => false - no "tralala" (if put fully, &tralala;) is not a recognised named HTML entity's name

// => true - yes "Aogon" (if put fully, Ą) is a recognised named HTML entity's name

You must use Set methods: has, size etc on notEmailFriendlySetOnly. It's not an array, it's a set.


notEmailFriendlyLowercaseSetOnly is also a Set but all values are lowercase and sorted.

The idea is that if you have a named HTML entity and suspect that its letter case might be messed up, you lowercase it and match against this Set. Now, if something is found, do actions matching against plain object keys in notEmailFriendly (aiming to decode to numeric entities), OR matching against a Set with exact case, notEmailFriendlySetOnly (if value is not found, letter case in your entity is messed up).

const { notEmailFriendlySetOnly } = require("html-entities-not-email-friendly");
for (const entitysName of notEmailFriendlySetOnly) {
// => "AMP",
// "Abreve",
// ...

notEmailFriendlyMinLength and notEmailFriendlyMaxLength

Their point is to give you guidance how long or short entities can be:

const {
} = require("html-entities-not-email-friendly");
`The shortest length in the set is: ${notEmailFriendlyMinLength} and longest is ${notEmailFriendlyMaxLength}.`
// => The shortest length in the set is: 2 and longest is 31.

Keep in mind, length here does not count ampersand and semicolon. For example, Abreve length is 6 characters but in the HTML, it is 8: Ă,

In practice

This program allows detergent to automatically switch between named and numeric HTML entities, prioritising on named, if they're supported (acccording this program).

Detergent's competitor, Email on Acid Character Converter opens in a new tab only uses numeric entities. Not to mention, EoA Character Converter ignores invisible characters, which is a liability.


See it in the monorepo opens in a new tab, on GitHub.


To report bugs or request features or assistance, raise an issue on GitHub opens in a new tab.

Any code contributions welcome! All Pull Requests will be dealt promptly.


MIT opens in a new tab

Copyright © 2010–2021 Roy Revelt and other contributors

Related packages:

📦 detergent 8.0.1
Extracts, cleans and encodes text
📦 emlint 5.0.1
Pluggable email template code linter
📦 all-named-html-entities 2.0.1
List of all named HTML entities
📦 html-crush 5.0.1
Minifies HTML/CSS: valid or broken, pure or mixed with other languages
📦 stristri 4.0.1
Extracts or deletes HTML, CSS, text and/or templating tags from string
📦 string-strip-html 9.0.1
Strips HTML tags from strings. No parser, accepts mixed sources
📦 detect-is-it-html-or-xhtml 5.0.1
Answers, is the string input string more an HTML or XHTML (or neither)