HTML Entity Encoder / Decoder
Escape HTML special characters as named, decimal or hex entities and decode entities back to text. Handles emoji correctly. Runs entirely in your browser.
Your inputs and files stay in your browser
Type HTML or text to escape, or paste entities such as < to decode them.
The escaped or decoded text appears here.
On this page
Escape ampersands, angle brackets, quotes and non-ASCII characters as HTML entities, or turn entities back into plain text. The tool is plain JavaScript running in your browser, so the markup you paste is not sent anywhere.
Detailed Functionality
Three encode modes cover the usual cases. The special-characters mode, the default, escapes the five characters that matter in HTML markup and attributes: &, <, >, " and '. The non-ASCII mode leaves markup alone and converts accented letters, symbols and emoji, which helps when a template or email has to stay pure ASCII. The all-characters mode does both.
Entities can be written as named (&, ©), decimal (©) or hexadecimal (©) references. Only about 30 common symbols have names in this tool, such as ©, —, € and ; other characters fall back to hex references even in named format. Emoji and other characters outside the Basic Multilingual Plane become a single reference such as 😀.
Decoding understands the same named entities plus decimal and hex references (©, ©, ©) and works in one pass, so &lt; correctly becomes < rather than <. Unknown names such as ♥ and references without the closing semicolon are left as they are.
Practical Examples
Escape markup: <a href="x">Tom & Jerry</a> becomes <a href="x">Tom & Jerry</a> with the default settings.
Non-ASCII only: © 2026 — café <b> becomes © 2026 — café <b>: the tag stays as it is, and é, which has no name in the list, falls back to hex.
Emoji: in all-characters mode, 😀 © becomes 😀 © in decimal format and 😀 © in hexadecimal.
Decoding: <p> © 😀 € decodes to <p> © 😀 €, while &lt; decodes to <.
How to Use This Tool
Paste your text
Type or paste plain text or HTML into Text to encode/decode.
Choose the mode and format
In Encode mode, pick
Only special characters (& < > " '),Only non-ASCII charactersorAll characters (special + non-ASCII). In Entity format, pickNamed (&),Decimal (&)orHexadecimal (&). These settings affect encoding only.Encode or decode
Click Encode to HTML to escape the text or Decode from HTML to turn entities back into characters.
Copy the result
Click Copy to take the output to the clipboard. Swap moves it back into the input, for example to decode a second layer.
Tips and Best Practices
- For text placed inside HTML elements or quoted attributes, escaping the five special characters is enough; non-ASCII text does not need entities when the page is served as UTF-8.
- Escaping is not a complete XSS defense: values placed in
href, inside<script>or in CSS need context-specific handling such as URL validation or JSON encoding. - The apostrophe is encoded as
', or'in decimal format, rather than', which HTML 4 did not define. - Decoding is a single pass: text escaped twice, like
&amp;, gives&first; click Swap and decode again. - Only the named entities from the built-in list are decoded; numeric references work for every Unicode character.