HTML Entity Encoder and Decoder – Escape and Unescape HTML
Escape text so it can be shown safely inside HTML, turning characters like &, <, > and quotes into entities, or decode entities such as &, © and € back into readable characters. Optionally encode every non-ASCII character as a numeric entity.
How to use the HTML entity encoder
- Choose Encode or Decode.
- Paste your text or HTML.
- When encoding, tick Also encode non-ASCII characters if you need pure ASCII output.
Press Use as input to reverse the result.
The five essential escapes
| Character | Entity |
|---|---|
& | & |
< | < |
> | > |
" | " |
' | ' |
Example
<p class="note">Fish & chips</p> encodes to
<p class="note">Fish & chips</p>
which a browser displays as the original code rather than as a paragraph.
Common named entities
| Entity | Character |
|---|---|
© | © |
® | ® |
™ | ™ |
€ | € |
£ | £ |
— | — |
… | … |
× | × |
° | ° |
| non-breaking space |
The decoder understands these and other common named entities, plus every numeric entity in decimal (€) or hex (€) form, including emoji.
When to escape
- Displaying code in a blog post, tutorial or documentation.
- Inserting user input into HTML on a server — though templating engines and frameworks such as React usually escape automatically, which is safer than doing it by hand.
- Writing HTML email for clients with limited character support.
- Storing snippets in XML or HTML attributes.
Entities in code and frameworks
Most modern frameworks escape text for you. React, Vue, Angular, Django, Rails and Laravel templates all escape values by default, which is why you rarely need to write entities by hand. Escaping becomes your job when you build HTML strings manually, use raw-HTML features such as dangerouslySetInnerHTML or v-html, or generate HTML email. In those cases, escape every piece of user-supplied text before inserting it.
Double escaping
If you see text like &amp; or &lt; on a page, the content has been escaped twice — once when it was saved and again when it was displayed. Decode it once with this tool to see what the original text was, then fix the code so escaping happens in only one place, ideally at the moment the text is output.
Attributes need quotes
Always put attribute values in quotes after escaping them. An unquoted attribute can be broken by a space, even when every special character has been escaped.
Unquoted attributes are also harder to read and review, so quoting them is good practice anyway.
Numeric or named?
Named entities are easier to read, but only a fixed set exists. Numeric entities work for every Unicode character, which is why the encoder uses them for non-ASCII text.
Escaping is context-dependent
HTML escaping protects text placed between tags and inside quoted attributes. It is not enough inside JavaScript, CSS or URLs — each has its own escaping rules. For URLs, use the URL encoder. For converting Markdown into HTML, try the Markdown to HTML converter.
Frequently asked questions
What is an HTML entity?
A code that represents a character in HTML. It starts with & and ends with a semicolon: named entities like © for ©, or numeric ones like © (decimal) and © (hex).
Which characters must be escaped in HTML?
& and < always, > for safety, and " or ' inside attribute values. Escaping these five covers almost every case.
Why escape HTML?
To show code as text on a page, and to stop user input from being treated as HTML. Not escaping user input is the main cause of cross-site scripting (XSS) attacks.
Do I need entities for accented letters?
Not if your page uses UTF-8, which almost all modern pages do. Encoding non-ASCII characters is only needed for systems that can’t handle UTF-8, such as some old email tools.
What is ?
A non-breaking space. It looks like a normal space but stops the browser from breaking the line at that point — useful between a number and its unit, such as 10 kg.
Is my text uploaded?
No. Encoding and decoding happen in your browser.
Related tools
URL Encoder / Decoder
Percent-encode or decode URLs, with a query-parameter table.Markdown to HTML
Markdown to HTML with tables and a safe live preview.Base64 Encoder / Decoder
Encode and decode Base64 and Base64URL with UTF-8 support.JSON Formatter
Pretty-print, validate and minify JSON with clear error positions.Regex Tester
Test regex live: matches, groups, flags and replace.
Last updated: