Overview
Introduction
Hexadecimal HTML/XML character references are a real, standard way to represent any Unicode character in markup using its code point in hex, written as &#xHHHH;.
This tool encodes every character of your input this way, correctly handling characters outside the Basic Multilingual Plane (like most emoji) by iterating per Unicode code point rather than per UTF-16 code unit.
What Is Characters to Hex HTML Entities Converter?
A hexadecimal character reference is the sequence &#x, followed by a Unicode code point written in hexadecimal, followed by a semicolon. "é" (code point U+00E9) becomes é.
Both HTML and XML parsers recognize this notation for any valid Unicode code point, unlike the small, fixed set of named entities (like & or ©), which only cover specific characters.
How Characters to Hex HTML Entities Converter Works
The tool spreads the input string into an array of Unicode code points (not raw UTF-16 code units), so multi-code-unit characters like emoji are treated as a single character rather than two broken halves.
Each code point is converted to hexadecimal via toString(16), uppercased, and wrapped in the &#x...; reference syntax, then all references are concatenated in the original order.
When To Use Characters to Hex HTML Entities Converter
Use this when you need every character of some text represented explicitly by its Unicode code point, for instance while debugging character-encoding issues, building test fixtures, or embedding text in a system that only reliably supports ASCII markup.
For markup-safety escaping (protecting against XSS when inserting untrusted text into HTML), use this site's HTML Entity Encoder tool instead, which escapes only the five HTML-significant characters rather than every character.
Often used alongside Hex HTML Entities to Characters Converter.
Features
Advantages
- Uses a real, standard notation understood by every HTML and XML parser, not an invented format.
- Correctly handles the full Unicode range, including characters outside the Basic Multilingual Plane like most emoji.
- Fully reversible with the companion hex-html-entities-to-characters-converter tool.
Limitations
- Encodes every character, not just markup-significant ones, so output is far more verbose than the five-character HTML Entity Encoder tool for typical markup-safety use cases.
- Numeric character references don't carry any semantic meaning the way some named entities do (e.g. © documents intent as well as encoding the symbol).
- Doesn't validate that the input is meant for HTML/XML at all; it will happily encode any text you give it.
Examples
Best Practices & Notes
Best Practices
- Use this for code-point-explicit representations of arbitrary text, not as a substitute for markup-safety escaping (use the HTML Entity Encoder tool for that).
- Pair with hex-html-entities-to-characters-converter to confirm a lossless round trip on your own text, including any emoji.
- Remember output is verbose (roughly 6-9 characters per input character), so this isn't a compact encoding.
Developer Notes
Implemented with the spread operator over the input string (`[...input]`), which iterates by Unicode code point per the ECMAScript string iterator protocol, then `codePointAt(0)!.toString(16).toUpperCase()` per character. This correctly handles astral characters (surrogate pairs) as a single unit, unlike a naive `for (let i = 0; i < input.length; i++)` loop over UTF-16 code units, which would split them incorrectly.
Characters to Hex HTML Entities Converter Use Cases
- Producing a code-point-explicit representation of arbitrary Unicode text, including emoji
- Debugging character-encoding issues by seeing every character's exact code point
- Generating test fixtures or documentation examples that show a string's underlying Unicode code points
Common Mistakes
- Using this tool when you actually want markup-safety escaping; use the HTML Entity Encoder tool for the five HTML-significant characters instead.
- Assuming per-UTF-8-byte encoding is happening; this encodes per Unicode code point, matching how HTML/XML character references are actually defined.
- Expecting a compact output; every character expands to several characters of reference syntax.
Tips
- Round-trip through hex-html-entities-to-characters-converter to verify correctness, especially for emoji or other non-BMP characters.
- If you only need to escape markup-significant characters, use the string category's HTML Entity Encoder tool instead of this one.