Numeric HTML entities reference characters by their Unicode code point rather than by name, so any character at all can be written in pure ASCII. This tool encodes text to decimal or hexadecimal numeric references and decodes them back.
How it works
Encoding reads each Unicode code point of the input and emits it as a numeric reference in the base you choose:
decimal: char -> &#<codePoint>; "A" -> A " " ->  
hex: char -> &#x<HEXcodePoint>; "A" -> A " " ->  
Because it works on full code points (via the string iterator), characters above
U+FFFF such as emoji become one entity, not a broken surrogate pair. Decoding
parses &#NN; and &#xNN;, converts the number to a code point, and rebuilds
the original character with String.fromCodePoint.
Decimal vs hex — when each form is preferred
Both forms are semantically identical: é and é are the same é to every browser. The practical difference is readability and context:
- Decimal is more readable for developers who think in decimal code points and is the form used in most documentation examples.
- Hex aligns naturally with CSS
\00E9escape syntax and Unicode charts, which list code points in hexadecimal, making it easier to cross-reference. - Some older XML processors and HTML-to-text email converters handle one form better than the other, so if a system rejects one, try the other.
Worked example
For example, encoding the word café to decimal numeric entities produces:
c → c
a → a
f → f
é → é
The full encoded string is café. Every character, including the plain ASCII letters, is replaced, making the result completely ASCII-safe.
The non-breaking space U+00A0 becomes   in decimal and   in hex. Non-breaking spaces are invisible to the eye but cause layout differences, and encoding them as numeric entities makes them visible and portable in email templates.
An emoji such as 🎉 sits at code point U+1F389 (above U+FFFF) and encodes as the single entity 🎉 in decimal — not as a pair of surrogate half-values, which would be wrong.
When to use numeric encoding vs named entities
Numeric encoding encodes every character, turning the output into a fully ASCII string with no multibyte sequences. This is the right choice for:
- Email templates and legacy mailers — some clients mis-render raw UTF-8 but handle numeric references reliably.
- XML documents — XML only recognises a handful of named entities by default; numeric references work universally.
- Exported data that must pass through systems of unknown encoding.
If you only need to escape the characters that break HTML markup (<, >, &, ") while keeping the rest readable, the named-entity tool is a lighter touch.
Common mistakes to avoid
- Forgetting the trailing semicolon renders the entity wrong in some parsers —
é(no semicolon) may not be recognised. The tool always adds the semicolon. - Decoding nested encoded text twice is a common mistake: if text has already been HTML-decoded once, running it through a decoder a second time will misparse any literal
&in the decoded output. - Encoding already-encoded entities turns
&into&amp;, double-encoding the ampersand. If your input has already gone through HTML encoding, decode it first.