HTML Entity Encoder and Decoder
Encode and decode HTML named, decimal and hexadecimal entities.
Escape XML special characters for text content or attribute values, or decode named entities and numeric character references back into readable text. Processing happens locally in your browser.
Input is processed as text. The tool does not load DTDs or resolve external entities.
The selected context controls whether quotes or apostrophes are escaped.
Required XML syntax characters are still escaped according to context.
Optional normalization may change how some Unicode characters are represented.
Escape mode treats input as plain text, so existing entity references may be escaped again.
This XML entity encoder escapes special XML syntax characters for text nodes, double-quoted attributes or single-quoted attributes. It can also decode XML entities, decimal character references and hexadecimal character references. The converter treats all input as text, so it does not validate complete XML documents, load DTDs, resolve external entities or fetch external resources.
XML markup escaped as text:
<note author="Ana">Café & tea isn't ready</note>
Escaped in text-content mode:
<note author="Ana">Café & tea isn't ready</note>
Text-content example:
Tom & Ana < Developers
Tom & Ana < Developers
Double-quoted attribute example:
Ana "Admin" & Team
Ana "Admin" & Team
<user title="Ana "Admin" & Team"/>
Single-quoted attribute example:
Ana's Team & Support
Ana's Team & Support
<group name='Ana's Team & Support'/>
Text nodes require escaping ampersands and less-than signs. This tool also escapes greater-than signs as > for predictable output. Double-quoted attributes require double quotes to be escaped; single-quoted attributes require apostrophes to be escaped. Escaping both quotation styles in every context is valid XML but unnecessarily verbose, so the context selector produces minimal context-aware output.
| Character | Text content | Double-quoted attribute | Single-quoted attribute |
|---|---|---|---|
& | & | & | & |
< | < | < | < |
> | > | > | > |
" | Preserved | " | Preserved |
' | Preserved | Preserved | ' |
XML defines five predefined named entities. HTML has many more named entities, but those are not automatically available in XML unless a document defines them separately.
| Character | Entity | Typical use |
|---|---|---|
& | & | Required before literal ampersands |
< | < | Required before literal less-than signs |
> | > | Valid and useful for consistent escaping |
" | " | Required in double-quoted attributes |
' | ' | Required in single-quoted attributes |
Decimal references use &#NUMBER; and hexadecimal references use &#xHEX;. Both represent Unicode code points and require a terminating semicolon. Hexadecimal digits are case-insensitive when decoding, and this tool outputs uppercase hexadecimal digits for consistency. For example, é and é both represent é, while 😀 represents 😀.
Escape mode treats input as plain text. Existing ampersands are escaped, so & becomes &amp;. Use Unescape mode first when the goal is to decode existing entities. This tool does not attempt to resolve custom entities declared in a DTD.
Unknown named entities and malformed numeric references are preserved. Invalid Unicode code points, surrogate code points and XML-invalid characters are not decoded from numeric references. The tool reports these problems instead of silently deleting content, and no external entity resolution occurs.
This tool processes text with JavaScript directly in your browser. Your input is not submitted to UnicodeNow servers. The converter does not load DTDs, resolve external entities or fetch external resources.
Choose Escape, select the XML context, and process the text. Ampersands, less-than signs and other context-required characters are converted to XML-safe entity references.
Ampersands and less-than signs must be escaped in text. Double-quoted attributes also need double quotes escaped, and single-quoted attributes need apostrophes escaped.
Select Double-quoted attribute or Single-quoted attribute before escaping. The tool then escapes the quote character that matches the delimiter and preserves the other quote style.
Both represent the less-than character. < is one of XML's five predefined named entities, while < is a decimal numeric character reference.
Choose Unescape to decode the five predefined XML entities plus valid decimal and hexadecimal numeric character references.
Yes in Escape mode. Input is treated as plain text, so & becomes &amp;. Use Unescape first when the goal is to decode existing entities.
No. It treats input as text and does not load DTDs, resolve external entities, fetch URLs or validate XML schemas.
No. This browser-local converter processes text with JavaScript and does not submit your input to UnicodeNow servers.
For HTML-specific named entities, use the HTML Entity Encoder and Decoder. For Unicode code points and numeric references, use the Unicode Escape Converter. For structured JSON strings, use the JSON Escape and Unescape tool.
Encode and decode HTML named, decimal and hexadecimal entities.
Escape and unescape JSON string content safely.
Escape JavaScript string literals and decode JS escape notation without eval.
Escape and unescape PHP-style single and double quoted strings.
Convert Python string escapes without executing Python code.
Convert text to and from Unicode escape sequences and numeric entities.
Unicode defines characters and code points. UTF-8 encodes those code points as bytes for files, databases, web pages, APIs and network messages.
Learn how Unicode escape syntax works across JavaScript, JSON, Python, PHP, Java, HTML, CSS and URLs.
Compare literal Unicode characters, named HTML entities, numeric character references, code points and UTF-8 bytes.