HTML Entity Encoder/Decoder — Escape Text
Encode and decode HTML entities for special and non-ASCII characters
Runs in your browser · nothing is uploaded
What it is
In HTML, characters like < and & have special meaning, so to show them literally you write entities such as < and &. This tool converts text to entities and entities back to characters.
How to use
- Choose Encode or Decode.
- When encoding, choose the scope: only the required five characters, or every non-ASCII character as a numeric reference.
- Paste your text and the result appears right away.
- Copy the result, or press Use output as input to check the round trip.
How it works
- Required-five mode:
&becomes&,<becomes<,>becomes>,"becomes"and'becomes'. - All non-ASCII mode: the five above, plus every character with a code point of 128 or more as a decimal reference (
éfor é). An emoji is treated as one code point, not two UTF-16 halves. - Decoding: named, decimal (
A) and hex (A) references are resolved in a single pass, so&lt;becomes<and goes no further. - Named references come from a built-in table of about fifty (amp, lt, gt, quot, apos, nbsp, copy, euro, hellip and so on). Names outside the table stay as they are.
- Numeric references for 0, the surrogate range or beyond the Unicode limit turn into the replacement character U+FFFD, as the HTML standard says.
Examples
| Input | Mode | Result |
|---|---|---|
<a href="x"> |
Required five | <a href="x"> |
é© |
All non-ASCII | é© |
👍 |
All non-ASCII | 👍 |
© 👍 |
Decode | © 👍 |
FAQ
Why encode text as HTML entities?
Text dropped into a page as-is has characters like < read as markup. Turning the required characters into entities makes them display literally and helps prevent injected scripts. It does not replace proper output escaping on your server.
Which five characters are required?
The ampersand, less-than, greater-than, double quote and single quote. They become & < > " and '.
Do I need to encode accented or Asian characters too?
Not if your document is UTF-8. Use the all non-ASCII mode only when the text goes somewhere with an uncertain encoding or a system that accepts ASCII only.
Some entities do not decode.
HTML defines over two thousand named entities. This tool includes about fifty common names plus all numeric references; names it does not know are left untouched.
Related tools
URL Encoder/Decoder
A URL percent-encoder and decoder that handles Unicode and emoji
Base64 Encoder/Decoder
A Base64 encoder and decoder that gets Unicode right
JWT Decoder
Decode JWT header and payload and check expiry (no signature verification)
Unicode Converter
Convert text to and from Unicode code points, escapes and UTF-8 bytes
HTML to Image
Renders pasted HTML and CSS and captures it as a PNG at a chosen width and scale