Skip to content

HTML entity encoder and decoder

Convert special characters like <, >, & and quotes to HTML entities and back, entirely in your browser.

38 characters

HTML entities

0 characters

How it works

An HTML entity is a short code that stands in for a character a browser would otherwise treat as markup, such as < or &, so it prevents special characters from being read as HTML tags.

  1. Paste your text

    The Plain text box already updates the Entities box as you type.

  2. Choose how much to encode

    Leave the toggle off for just the five special characters, or turn it on for every non-ASCII character too.

  3. Copy the result

    Or edit the Entities box directly and click Decode to get plain text back.

Common HTML entities

CharacterEntity nameEntity number
<&lt;&#60;
>&gt;&#62;
&&amp;&#38;
"&quot;&#34;
'&apos;&#39;
©&copy;&#169;
®&reg;&#174;
(non-breaking space)&nbsp;&#160;

Entity encoding and XSS

Entity encoding is an essential defense against cross-site scripting but not a complete strategy on its own. It works correctly for text placed inside an HTML element's body. User input placed inside a JavaScript string, an HTML attribute, CSS or a URL parameter needs different, context-specific escaping. Always use a security-focused library or framework rather than relying on a single encoding pass.

Named entities versus numeric references

A named entity uses a readable identifier, such as &amp; for &. A numeric reference uses the decimal (&#38;) or hexadecimal (&#x26;) Unicode code point instead. Named entities only cover a defined set of characters; numeric references can represent any Unicode character, which is what the "encode all non-ASCII characters" option above uses.

Nothing leaves your device

Both encoding and decoding run entirely in your browser using JavaScript and the DOM. No text is transmitted to any server, so it is safe to paste sensitive content, authentication tokens embedded in HTML, or internal application markup.

Frequently asked questions

How do I encode special characters as HTML entities to prevent XSS?

Type or paste the raw text into the Plain text box. It replaces each of the five special characters, <, >, &, " and ', with its HTML entity equivalent as you type: < becomes &lt;, > becomes &gt;, & becomes &amp;, " becomes &quot; and ' becomes &#39;. This encoding prevents a browser from reading the text as markup.

Is HTML entity encoding a complete XSS prevention strategy?

Entity encoding is an essential defense but not sufficient on its own. It works correctly for HTML content context, text inside element bodies. However, user input placed inside JavaScript strings, HTML attributes, CSS, or URL parameters requires different escaping strategies. Always apply context-specific output encoding and use a security-focused library or framework rather than relying solely on a single encoding pass.

How do I decode HTML entities back to readable text?

Paste the entity-encoded text into the HTML entities box and click Decode to plain text. The tool converts each named or numeric entity back to its corresponding character. This is useful when extracting text from HTML source, reading escaped strings in logs, or inspecting server-side output.

Is my text sent to a server when encoding or decoding HTML entities?

No. Both encoding and decoding run entirely in your browser using JavaScript and DOM manipulation. No text is transmitted to any server, making it safe to paste sensitive content, authentication tokens embedded in HTML, or internal application markup.

What is the difference between named HTML entities and numeric character references?

Named entities use a human-readable identifier preceded by & and followed by ;, for example &amp; for &. Numeric references use the decimal (&#38;) or hexadecimal (&#x26;) Unicode code point. Named entities are limited to a defined set; numeric references can represent any Unicode character. Both are valid HTML5 and produce identical results in a browser.

Can this tool encode more than the five basic special characters?

Yes. Turn on "Also encode all non-ASCII characters" to convert every character outside the printable ASCII range, accented letters, symbols and emoji included, into a numeric entity as well as the five special characters. This is useful when preparing text for an older system that only accepts plain ASCII markup.