HTML Entity Encoder/Decoder
Encode special characters to HTML entities or decode them back.
What the HTML entity decoder and encoder does
HTML character references represent characters that would otherwise be ambiguous in markup. The encoder replaces reserved characters such as ampersand, less-than, greater-than, quotation mark, and apostrophe. Its extended option also emits decimal references for non-ASCII characters. The decoder resolves named, decimal, and hexadecimal references using the browser HTML parser.
HTML entity examples
- < becomes the less-than character, while > becomes greater-than.
- & becomes an ampersand and " becomes a quotation mark.
- © and © are decimal and hexadecimal references for the copyright symbol.
- Encoding <p>Research & Development</p> produces text that can be displayed as markup characters instead of being parsed as the same element.
Security and rendering boundaries
Entity encoding is context-sensitive. Escaping text for an HTML text node does not make the same value safe inside an event handler, URL, CSS declaration, JavaScript string, or arbitrary HTML fragment. Use framework escaping by default and a maintained sanitizer when trusted formatting must be preserved. Decoding untrusted entities should produce text for inspection, not a reason to inject the result with innerHTML.
Related developer tools
Continue with Image to Base64, HEX Encoder/Decoder, Binary Encoder/Decoder.
How to Use HTML Entity Encoder/Decoder
- Choose Encode to escape text or Decode to resolve character references.
- Paste the source text and optionally enable the extended encoding option.
- Select Encode or Decode, then review the converted output.
- Apply context-specific escaping or sanitization before using untrusted output in an application.
Frequently Asked Questions
What are HTML entities?
- HTML entities are special codes used to display reserved characters in HTML. For example, < represents < and & represents &.
Why encode HTML entities?
- Encoding reserved characters can keep text from being interpreted as markup in an HTML text context. It is not a complete XSS defense: attributes, URLs, CSS, JavaScript, and untrusted HTML require context-specific escaping or sanitization.
Which entity formats can this tool decode?
- It decodes browser-recognized named references such as &, decimal numeric references such as ©, and hexadecimal references such as ©.
Sources & references
Primary references: WHATWG HTML Living Standard.
Last reviewed: