Encodes text so it can be placed inside HTML without being interpreted as markup, and decodes entity-encoded text back to plain characters.
Encode modes:
- Only special characters escapes
& < > " '. This is enough for HTML text and attribute values. - Special + all non-ASCII also escapes accented letters, symbols and emoji, which helps when a file must stay pure ASCII.
- Everything except letters, digits and spaces for maximum caution.
With Prefer named entities on, common characters use readable names like ©, é or —; everything else gets a hex reference like 😀.
Decoding supports every named entity the browser knows plus decimal and hex references. It uses a detached element that treats the input as text, so tags in the input are never rendered or executed.