HTML entity escaper

Encode text into safe HTML entities or decode entities back to plain text — instantly and privately in your browser.

Quick reference — click any card to copy the entity

What HTML entity escaping is for

A browser reads <, > and & as instructions, not as text. The moment one of those characters appears in content where the parser expected plain text, the page can break — a tag opens that should not, an attribute value is cut short, or, in the worst case, a script someone slipped into a comment field actually runs. Entity escaping replaces each risky character with a safe stand-in (an entity) that displays as the original glyph but carries no structural meaning. This tool does that conversion both ways: encode raw text into entities, or decode entities back into the characters they represent.

A worked example

Suppose a user types <img src=x onerror=alert(1)> into a comment box and you drop it straight into your page. The browser sees a real image tag and fires the onerror handler — a classic cross-site scripting (XSS) attack. Encode it first and it becomes inert text:

&lt;img src=x onerror=alert(1)&gt;

Now the browser prints the literal angle brackets instead of building an element, and nothing executes. Paste that encoded string into the Decode tab and you get the original text back — safely, because decoding here never inserts live markup into the page.

The five characters that must be escaped

Modern UTF-8 pages render accented letters and symbols natively, so you rarely need to escape them. These five, however, are reserved and should be escaped whenever text is embedded in markup:

GlyphNamed entityNumericWhy it matters
&&amp;&#38;Starts every entity, so it must be escaped first.
<&lt;&#60;Opens an HTML tag.
>&gt;&#62;Closes an HTML tag.
"&quot;&#34;Ends a double-quoted attribute value.
'&#39;&#39;Ends a single-quoted attribute value.

Note that &apos; is valid in XML but not in legacy HTML, which is why the numeric &#39; is the safer choice for the apostrophe.

Privacy note: encoding and decoding run entirely in your browser with no network calls and no logging. You can safely paste snippets that contain tokens, internal markup or untrusted input — the text never leaves this tab.

Frequently asked questions

Which characters does “special characters only” escape?

It escapes the five characters that can break HTML: the ampersand (&), less-than (<), greater-than (>), double quote (") and single quote ('). The ampersand is always converted first so existing entities are not double-encoded. This is the right mode for safely embedding text inside page content or attribute values.

What does the “all non-alphanumeric” mode do?

It converts every character that is not a letter, digit or space into a numeric decimal entity such as &#233; for é or &#128512; for an emoji. This is useful for legacy systems or strict ASCII-only contexts, but it produces longer output and is rarely needed on modern UTF-8 pages.

Is it safe to paste untrusted or malicious HTML here to decode it?

Yes. Decoding is done with a detached textarea element, which resolves entities to plain text without ever inserting live markup into the page. A pasted <script> tag is turned back into harmless text, never executed. Encoding and decoding both run entirely in your browser.

Will encoding twice double-escape my text?

It can. Because the ampersand is itself escaped to &amp;, running already-encoded text through the encoder again turns &lt; into &amp;lt;. Encode once on the way out, and decode once on the way in. If you are unsure, decode first and then encode fresh.

What is the difference between named and numeric entities?

Named entities like &copy; or &lt; are human-readable but only exist for a fixed set of characters. Numeric entities like &#169; or &#x3C; reference a Unicode code point directly and can represent any character, including emoji. Both decode to exactly the same glyph.