HTML Entity Encode / Decode
Escape text so it shows as-is inside HTML, or decode named and numeric entities back to characters.
What it is for?What it is for?
HTML entities let you show characters that would otherwise be read as markup. Use Encode when you want a code sample to appear on a page as text, when you put user text into an HTML template by hand, or when you write a value into an attribute. Use Decode when an API, a feed or a database gives you text full of entities and you want the plain characters back.
Which characters are escaped
Encode replaces the five characters that HTML treats as markup: ampersand, less than, greater than, double quote and single quote. That is enough for text and attribute values. With non-ASCII on, letters such as ç or emoji become numeric references too, which helps when a file or an e-mail is not stored as UTF-8. Decode understands named, decimal and hexadecimal entities.
The ampersand becomes amp, the double quote becomes quot and the single quote becomes the numeric reference 39, so the output works in both single and double quoted attributes. With non-ASCII on, ç becomes reference 231.
Common mistakes
- Encoding twice. Text that is already escaped gets its ampersands escaped again, and the page then shows the entity names instead of the characters. Decode first if you are not sure.
- Using it for the wrong context. Entities protect HTML text and attributes. A value inside a URL needs URL encoding, and a value inside a script needs JavaScript string escaping.
- Escaping by hand in a template. Laravel Blade, Twig and React escape output for you; use this tool to check or debug, not to replace that.
Where it runs
Both directions run in this tab. Decode uses the browser's own HTML parser, so it knows every named entity the browser knows. Nothing is sent to our server.