HTML Entity Encoder & Decoder
Developer Tools · Added
Turn characters into HTML character references and back again. The default escapes only the five characters HTML actually reserves, which is what a templating engine does and what you almost always want; wider scopes and numeric formats are there for the cases where you need them. A breakdown table shows every character being replaced, in all three notations at once.
Result
- Characters replaced
- 7
- Length
- 37 → 63
Characters in, characters out
| Character | Named | Decimal | Hex | Code point |
|---|---|---|---|---|
| < | < | < | < | U+003C |
| " | " | " | " | U+0022 |
| > | > | > | > | U+003E |
| & | & | & | & | U+0026 |
Decoding runs once, not repeatedly. That matters more than it sounds: decoding &lt; twice would turn a documented example of an escaped tag into a live one, which is the shape of a great many cross-site scripting bugs. Escaping is also not sanitisation — it makes text safe to display, and does nothing about markup you actually intend to render.
The references worth knowing
| Character | Named | Numeric | What it is |
|---|---|---|---|
| & | & | & | The one that has to be escaped first |
| < | < | < | Opens a tag |
| > | > | > | Closes a tag |
| " | " | " | Ends an attribute value in double quotes |
| ' | ' | ' | Ends an attribute value in single quotes |
| |   | Non-breaking space | |
| © | © | © | Copyright |
| ® | ® | ® | Registered trademark |
| ™ | ™ | ™ | Trademark |
| ° | ° | ° | Degree |
| € | € | € | Euro |
| £ | £ | £ | Pound |
| ¥ | ¥ | ¥ | Yen |
| – | – | – | En dash, for ranges |
| — | — | — | Em dash, for asides |
| ‘ | ‘ | ‘ | Left single quote |
| ’ | ’ | ’ | Right single quote, also the apostrophe |
| “ | “ | “ | Left double quote |
| ” | ” | ” | Right double quote |
| … | … | … | Ellipsis |
| × | × | × | Multiplication sign |
| → | → | → | Right arrow |
| ≤ | ≤ | ≤ | Less than or equal to |
| ≥ | ≥ | ≥ | Greater than or equal to |
How to use the html entity encoder & decoder
- 1Pick a direction — text to entities, or entities back to text.
- 2Paste your text or markup. Everything runs in this tab.
- 3Choose what to encode. Reserved only is the safe default; add non-ASCII if the output has to survive a system that mangles UTF-8.
- 4Choose a format. Named references are readable, numeric ones work everywhere, and hexadecimal matches how code points are written in Unicode charts.
- 5Leave invisible characters revealed to catch a non-breaking space or a zero-width joiner that has been pasted in without you noticing.
Examples
Escaping a tag so it displays
- Input
- <p class="lead">Tom & Jerry</p>
- Result
- <p class="lead">Tom & Jerry</p>
This is what you paste into a page to show markup rather than run it.
Decoding scraped text
- Input
- Café — £5
- Result
- Café — £5
Named, decimal and hexadecimal references all decode.
An entity that is not one
- Input
- Salt &pepper; and vinegar
- Result
- Left exactly as it is, with the sequence reported
Deleting an unknown reference would silently change your text.
Finding an invisible character
- Input
- A pasted price with a non-breaking space in it
- Result
- made visible in the output and listed in the table
About the html entity encoder & decoder
Three ways to write the same character
A character reference always starts with an ampersand and ends with a semicolon. In between it is either a name, a decimal code point after a hash, or a hexadecimal code point after a hash and an x. So é, é and é are three spellings of exactly the same character, and a browser treats them identically.
The semicolon is not optional in practice, even though some parsers will forgive its absence for historical reasons. Leaving it off produces markup whose meaning depends on which parser reads it, and this tool always emits it.
The invisible characters worth catching
Text pasted from a word processor, a PDF or a web page frequently carries characters that look like a space and are not: non-breaking spaces, thin spaces, zero-width joiners, and the occasional byte order mark that has survived a file conversion. They break string comparisons, they defeat search, and they are invisible in every editor that does not go looking for them.
Revealing them is on by default here for that reason. A non-breaking space rendered as in the output is immediately obvious, and the breakdown table labels it explicitly rather than showing a blank cell you would scroll straight past.
Where entities still earn their place
Three cases come up repeatedly. Showing code on a page, where the whole point is that the markup must not run. Email templates, where the rendering environment is genuinely unpredictable and the cost of a numeric reference is nothing. And characters that are ambiguous in source — a non-breaking space is worth writing as even in a UTF-8 file, precisely because the alternative is invisible.
Outside those, modern practice is to write the character itself and let the file's encoding carry it. A page full of é where an é would do is a page that is harder to edit for no benefit, and it usually indicates a pipeline that escaped its data twice.
Frequently asked questions
Which characters actually need escaping?
Do I need to escape é, — or emoji?
Named or numeric?
Why is decoding only done once?
Does escaping make user input safe?
How complete is the name table?
Related tools
URL Encoder / Decoder
Developer Tools
Percent-encode and decode URLs and query parameters, with a query string breakdown.
Base64 Encoder / Decoder
Developer Tools
Encode text to Base64 and decode it back, with full Unicode and URL-safe support.
HTML Formatter
Developer Tools
Beautify and indent HTML markup, or minify it for production.