What to escape, and where
- Inside an element, escape
&and<(and>for good measure):&,<,>. Otherwise<script>in user text becomes a real tag. - Inside a quoted attribute, also escape the quote character:
"for double quotes,'or'for single quotes. - Escaping protects against cross-site scripting only in these two places. In URLs, scripts and styles, use the escaping that language needs; for URLs, the URL Encoder.
- Pages served as UTF-8 don't need entities for accented letters or emoji; Also non-ASCII characters is for systems that only accept ASCII, such as some email templates.
How to use the HTML Entity Encoder / Decoder
- Choose Encode or Decode.
- Paste the text or HTML, or press Sample.
- When encoding, choose what to escape: element text, attribute values, all special characters, or non-ASCII characters too.
- Copy the result.
Examples
Escape a snippet to show it on a page
<a href="/search?q=fish&chips">Fish & chips</a><a href="/search?q=fish&chips">Fish & chips</a>Quotes don't need escaping in element text, so they're left alone.
Non-ASCII characters as entities
Café — 5 > 3 😀Café — 5 > 3 😀Characters with a named entity use it; others, such as emoji, get a numeric reference.
Decode entities
<p class="intro">Café & crème</p> © 2026 — 😀<p class="intro">Café & crème</p> © 2026 — 😀Decoding like a browser
Browsers accept some entities without their final semicolon, for historical reasons: © 2026 shows ©. The rules are subtle: ¬it; becomes ¬it; because ¬ is a legacy entity. This tool decodes exactly as browsers do, so the result matches what a page shows.
Options
- Encode / Decode
- Escape text for HTML, or turn entities back into characters.
- Escape
- Text content (& < >), attribute values (adds "), all special characters (adds '), or all of those plus every non-ASCII character.
- Named entities
- With non-ASCII characters: use names like
éwhere they exist, or numeric references likeéthroughout.
Limitations
- Encoding escapes the whole input as text: it doesn't parse HTML and leave tags alone.
- Escaping for JavaScript strings, CSS or URLs needs different rules.
Frequently asked questions
Is my text uploaded?
No. Encoding and decoding run in your browser; nothing you paste is sent anywhere.
What's the difference between ' and '?
Both mean a single quote. ' is defined in HTML5 and XML but not in HTML 4, so ' is the safer choice for old email clients; browsers today accept both.
How do I escape HTML in JavaScript?
Set element.textContent instead of innerHTML, and the browser escapes for you. To build a string, replace & first, then <, >, " and '. Frameworks such as React escape text automatically.
Why do I see &amp; on my page?
The text was escaped twice: & became &, then & became &amp;. Escape once, at the point where text is inserted into HTML.