ZapKit

HTML Entity Encoder & Decoder

Escape text so it shows literally in HTML instead of being read as markup, or turn &, € and other entities back into characters.

What are HTML entities?

HTML entities are codes that stand in for characters, written between an ampersand and a semicolon: &lt; for <, &amp; for &, &euro; for €. They let you show characters that would otherwise be read as markup, and type symbols that aren't on your keyboard.

Developers encode user input before inserting it into a page, technical writers escape code samples so tags show instead of rendering, and email builders encode accented characters for older clients. Decoding goes the other way, which helps when an API, feed or database hands back text full of &quot; and &#39;.

How to use the HTML Entity Encoder

  1. 1.Paste text or HTML

    Anything you want to show on a page as text, or a string full of entities.

  2. 2.Choose encode or decode

    When encoding, pick which characters to escape and the entity style.

  3. 3.Copy the result

    Paste it into your HTML, template or CMS.

Example: a price note with markup

Input: <p class="note">Fish & chips for £5 — "today" only</p>, encoding only the special characters with named entities:

<p class="note">
&lt;p class=&quot;note&quot;&gt;
Fish & chips
Fish &amp; chips
£5 —
unchanged (only the five specials)
With every non-ASCII too
&pound;5 &mdash;

Pasted into a page, the encoded version shows the tag as text instead of creating a paragraph.

Which characters need escaping

Five characters have special meaning in HTML: & starts an entity, < and > delimit tags, and " and ' close attribute values. Escaping just those is enough to display any text safely inside an element or a quoted attribute, and is the core defence against HTML injection.

Encoding every non-ASCII character as well is useful for old systems that mangle UTF-8, email templates, or source files that must stay pure ASCII. Named entities like &copy; are easiest to read; numeric ones work for every character, including emoji.

Frequently asked questions

What's the difference between &#38; and &amp;?

Nothing in the browser: both produce &. One is the decimal code point, the other a named entity.

Does escaping stop XSS?

Escaping the five special characters prevents injected markup in element content and quoted attributes. JavaScript, URLs and CSS contexts need their own encoding.

Why is &#39; used instead of &apos;?

&apos; isn't defined in HTML 4, so &#39; works in every browser and email client.

Can it decode entities without a semicolon?

Yes. Decoding follows the browser's rules, which accept common legacy forms like &amp without the semicolon.

More Developer tools