What is the HTML Entity Encoder / Decoder?
Some characters have a special meaning in HTML. < starts a tag and & starts an entity. To show them as text you must write them as HTML entities: <, >, &, " and '. Escaping user content this way is also a basic defence against cross-site scripting (XSS).
The encoder escapes these five characters. It can also turn every non-ASCII character into a numeric entity such as é, which is useful for old systems that do not handle UTF-8. The decoder understands all named entities (©, , €…) as well as decimal and hex numeric entities.
How to use the HTML Entity Encoder / Decoder
- Paste HTML or text into the input.
- Click Encode to escape it, or Decode to turn entities back into characters.
- Copy the output into your template, CMS or code.
Frequently asked questions
Which characters must be escaped in HTML?
In text content, always escape & and <. Inside attribute values, also escape the quote character you used. Escaping all five (& < > " ') is the safe default.
Does escaping HTML prevent XSS?
Escaping is essential when you insert untrusted text into HTML, but it is not enough in every context. JavaScript strings, URLs and CSS each need their own encoding. Use your framework's built-in escaping whenever you can.
What is the difference between &nbsp; and a space?
is a non-breaking space. It looks like a space, but browsers will not wrap a line there or collapse it with neighbouring spaces.