HTML Entities Encode / Decode
Escape special characters into HTML entities, or turn entities like &, é and 😀 back into plain text. Named, decimal and hexadecimal forms are all handled.
Use the tool
Why this tool exists
Putting a snippet of code or user text into an HTML page without escaping &, < and quotes breaks the layout, and in the worst case opens a cross-site scripting hole. In the other direction, scraped text and exported feeds arrive full of & and ’ that need turning back into characters.
This tool escapes the five characters that matter in HTML, and can also convert every non-ASCII character to a named or numeric entity. In decode mode it understands named, decimal and hex entities, and leaves unknown names untouched. It runs locally, so draft content stays private.
How to use it
- Paste your text or HTML into the box.
- Choose the direction: encode to produce entities, or decode to restore characters.
- For encoding, tick "Encode all non-ASCII" if the target cannot handle UTF-8.
- Copy the converted text.
Frequently asked questions
Which characters does encoding escape?
It always escapes & < > " and the apostrophe, which covers the characters that can break HTML markup or attributes. With "Encode all non-ASCII" it also converts accented letters, symbols and emoji to named or numeric entities.
Does it know every named entity?
It knows the five core ones plus a few dozen common names such as nbsp, copy, eacute, mdash and euro. Unknown names are left as they are. Numeric entities, decimal or hex, always work for any code point.
Is escaping enough to prevent XSS?
Escaping text placed in element content is a key defence, but the right escaping depends on context. Attributes, URLs, scripts and styles each need their own rules. Use a templating library that escapes by default.
Why does decode show a replacement character?
A numeric entity pointing to code point 0 or beyond the Unicode range cannot be a real character, so it becomes the replacement character, �.