HTML Entity Encoder & Decoder
Escape markup characters as named, decimal or hexadecimal entities, or decode entities back to the characters they represent. All processing happens locally in your browser.
Escape markup characters or turn entities back into text
Encoding replaces characters that would otherwise be parsed as markup. Decoding resolves named, decimal and hexadecimal references back to the characters they stand for.
The escaped source appears here as you type.
Only the characters selected above are replaced. Everything else is passed through byte for byte.
What is an HTML entity?
An HTML entity is a stand-in for a character, written so the browser stores the character without treating it as markup. Every entity starts with & and ends with ;.
The problem it solves: HTML uses < to start a tag and & to start an entity. If your content genuinely contains those characters, the parser cannot tell your text apart from your markup.
Write this in a page:
<p>5 < 10</p>
and the browser sees < 10</p> as the start of a tag. Escape the comparison operator and the meaning is unambiguous:
<p>5 < 10</p>
The page still displays 5 < 10. Only the source changed.
The five characters that matter
Long lists of entities exist, but only five characters can actually change how markup is parsed:
| Character | Named | Decimal | Hex | Why it needs escaping |
|---|---|---|---|---|
& |
& |
& |
& |
Starts every entity, so it must be escaped first |
< |
< |
< |
< |
Opens a tag |
> |
> |
> |
> |
Closes a tag |
" |
" |
" |
" |
Ends a double-quoted attribute value |
' |
' |
' |
' |
Ends a single-quoted attribute value |
Order matters when escaping. & has to go first, otherwise escaping < to < and then escaping ampersands turns it into &lt;. This tool handles all five in a single pass, so that ordering bug cannot occur.
On the apostrophe: ' is valid in XML and HTML5 but was never part of HTML 4. ' works everywhere, so that is what the named style outputs for '.
How to encode or decode entities
- Choose a direction Encode turns characters into references. Decode turns references back into characters.
-
Pick a reference style when encoding
Named produces
©, decimal produces©, hexadecimal produces©. All three render identically. - Choose what to escape “Markup characters only” touches the five above and leaves accented letters as readable text. “Markup plus all non-ASCII” escapes anything above code point 127 as well, which is useful for systems stuck on a legacy character encoding.
- Check the counters When encoding you see how many characters were replaced and how much the output grew. When decoding you see how many named, decimal and hex references were found and resolved.
Named vs numeric references
Both forms point at the same character. The difference is legibility versus universality.
Examples of the same character in all three styles
| Character | Named | Decimal | Hexadecimal |
|---|---|---|---|
| © | © |
© |
© |
| — | — |
— |
— |
| € | € |
€ |
€ |
| é | é |
é |
é |
| Non-breaking space | |
  |
  |
| 🙂 | (no name) | 🙂 |
🙂 |
Named references only exist for a fixed vocabulary. Emoji, most CJK characters and rarer symbols have no name at all, which is why the encoder falls back to a numeric reference automatically whenever no name applies.
The hexadecimal form is the one to reach for when working from a Unicode chart: U+2014 becomes — with no arithmetic. The decimal form requires converting 2014 from hex to 8212 first.
Double encoding, and how to recognise it
Double encoding is the most common entity bug. It happens when a string that is already escaped gets escaped again — usually because both a template engine and application code decided to be careful.
Original: <b>bold</b>
Escaped once: <b>bold</b>
Escaped twice: &lt;b&gt;bold&lt;/b&gt;
On the page, a double-escaped string displays as the literal text <b>bold</b> — visible entity codes instead of either bold text or the tags. That symptom, entities showing up in rendered output, always points at one escape too many somewhere in the chain.
This page flags input that matches the pattern & followed by another entity name, and you can send the output back to the input to peel off one layer at a time until the text is clean.
Entities are not the same as URL encoding
Both replace characters, but they apply to different layers and use different syntax. Mixing them up produces broken links.
| HTML entities | Percent encoding | |
|---|---|---|
| Applies to | Text inside an HTML document | Text inside a URL |
| Syntax | &name; or &#nn; |
% plus two hex digits |
| A space becomes | Unchanged (or when non-breaking) |
%20 |
| An ampersand becomes | & |
%26 |
A URL inside an href attribute can need both, in this order: percent-encode the query values, then entity-escape the resulting string for the attribute. So ?a=1&b=2 is written href="?a=1&b=2" in the source. Use the URL Encoder & Decoder for the percent-encoding half.
Use cases
- Publishing code in an article. Any HTML example shown as text has to be escaped, or the browser renders it instead of displaying it.
- Reading an escaped API response. Feeds and CMS exports frequently return
<p>where you expected markup. Decode to see the real content. - Auditing what a sanitiser did. Compare input and output to confirm the five markup characters were handled and nothing extra was mangled.
- Fixing entities that leaked into visible text. Decode the affected string to identify how many escape layers were applied.
- Preparing content for a legacy pipeline. Escaping all non-ASCII characters as numeric references keeps text intact through systems that are not reliably UTF-8.
- Finding invisible characters. Encoding non-ASCII reveals a non-breaking space as
 and a zero-width space as​, both of which are invisible in an editor.
Privacy and a security caveat
Encoding and decoding are string operations performed in your browser; the text is not uploaded to convert it.
Important: escaping is context-sensitive, so this tool is a debugging and authoring aid, not an XSS defence. Escaping the five markup characters is correct for HTML text nodes and quoted attribute values. It is not sufficient inside a <script> block, inside a style attribute, or in an unquoted attribute. Production applications should rely on their framework's context-aware output escaping.
Frequently Asked Questions
Do I have to escape every accented character?
No. On a UTF-8 page you can write é, €, 中 and emoji directly, and that is the normal modern choice because the source stays readable. Escaping non-ASCII characters is only worth doing when content must survive a pipeline whose character encoding you do not control.
Why does behave differently from a normal space?
is U+00A0, a distinct character from the ordinary space at U+0020. Browsers never collapse or line-break on it, which is what makes it useful for keeping "10 kg" together, and also what makes it a nuisance when it gets pasted invisibly into content and breaks a string comparison.
Which reference style should I use?
Named for the common few — <, >, &, ", , ©, — — because they are self-documenting. Hexadecimal when you are working from a Unicode code point, since U+2014 maps straight to —. Decimal mainly when a legacy system requires it.
Why does decoding leave some entities untouched?
Unrecognised names are preserved rather than deleted, and they are listed under the output so you can see what was skipped. This also matters for genuine text: in "Fish & Chips &co", the &co is not a valid reference, so it stays exactly as written.
Does decoding here strip HTML tags?
No. Decoding only rewrites entity references and leaves everything else byte for byte, so real tags in your input survive. That is deliberate — tools that decode by parsing the string as HTML silently discard the markup around the entities.
Is escaping these five characters enough to stop XSS?
Only for HTML text and quoted attribute values. Different contexts need different escaping: JavaScript string literals, CSS values, unquoted attributes and URL attributes each have their own rules. Use your framework's context-aware escaping in production and treat this page as a debugging tool.
What is the difference between an entity and a Unicode code point?
The code point is the character's number in the Unicode standard, written U+00E9 for é. An entity is one way to write that number inside an HTML document, as é or é or é. The code point is the identity; the entity is the transport syntax.