Maaz Zindani

Loading the index…

↑↓ move↵ openesc close3993 pages

Free tool · Developer tools

HTML entity encoder and decoder

Turn characters like &, <, quotes, é and € into HTML entities, or turn entities such as &amp;, &copy; and &#8364; back into text. It runs in your browser, so nothing you paste is uploaded.

  • Free
  • No sign-up
  • Runs in your browser

By Maaz Zindani · Updated

What do you want to do?
Characters to encode
Style

The apostrophe is written &#39;, which every HTML parser reads. Named style needs a name: characters without one fall back to a decimal reference.

Encoded text

Encoded8 characters written as references

&lt;a href=&quot;shop?x=1&amp;y=2&quot;&gt;Café &amp; crème – 5 € ©&lt;/a&gt;

    Entities make text safe inside HTML element text and quoted attribute values. They do not make it safe inside a URL, a script or a style block.

    Input
    47 characters
    Output
    77 characters
    Written
    8 references

    How to use the HTML Entity Encoder

    1. Choose Encode or Decode under What do you want to do?, then paste your text or HTML into the box.
    2. To encode, pick Characters to encode: only the 5 special ones, or those plus every non-ASCII character. Then pick the Style: named, decimal or hex.
    3. Read the result under Result. When decoding, the table lists each reference that was turned into a character, with its code point.
    4. Press Copy, Download or Use result as input, for example to decode text that was encoded twice.

    How do I encode special characters in HTML?

    Paste the text and keep Encode selected. An HTML character reference starts with an ampersand and ends with a semicolon, and comes in three forms: named (&copy;), decimal (&#169;) and hexadecimal (&#xA9;), all for the copyright sign. Only the 5 special ones writes &amp; for &, &lt; for <, &gt; for >, &quot; for a double quote and &#39; for an apostrophe. That is enough for a page saved as UTF-8, where é, € and 日本 can stay as they are. The apostrophe is written as a number because every parser reads it; &apos; exists in HTML5 and XML but not in HTML 4.

    Those, plus every non-ASCII character also replaces letters and symbols outside the ASCII range, which helps when the text will travel through something that is not UTF-8 safe. With Named style a character gets its name if it has one among the 252 HTML 4 names (&eacute;, &euro;, &trade;) and a decimal reference if it does not. An emoji is one reference, such as &#128512;, not two halves.

    Which characters must be escaped in HTML?

    It depends on where the text goes. The HTML Standard says element text must not contain a literal < or an ambiguous ampersand, which is an & followed by letters and a semicolon that do not form a known reference. A double-quoted attribute value cannot contain a literal double quote, and a single-quoted one cannot contain a single quote. So the reliable rule is to escape & and < in text, and & plus the quote you use in an attribute. Escaping all five characters, which is the default here, is correct in every one of those places.

    This is not a complete defence against script injection. Entity encoding protects text placed inside HTML element content or a quoted attribute. It does nothing for text placed inside a script block, a style block, an unquoted attribute or a URL, each of which has its own escaping rules.

    What is the HTML entity for the copyright symbol, and what is the difference between &nbsp; and a space?

    The copyright sign © is &copy;, &#169; or &#xA9;; its code point is U+00A9. The registered sign is &reg;, the euro is &euro; and the trademark sign is &trade;. Decode mode shows the code point of every reference it reads, so you can look up others by pasting them in.

    &nbsp; is the no-break space, U+00A0. A normal space can be collapsed with its neighbours into one by the browser and is a place where a line may wrap, while a no-break space is neither: it keeps "10 km" or "Mr. Smith" together on one line and is not merged. Because it looks like a space, it also causes trouble when it sneaks into data. Decode mode labels it as a no-break space instead of showing a blank.

    How do I decode HTML entities?

    Choose Decode and paste the text. Decoding is done by your browser's own HTML parser, so every named reference in the HTML Standard works, not just the common ones, and the browser's rules apply: a few older names such as &copy are read even without the semicolon, a name the standard does not know stays exactly as written, and a bare & stays an &. Numeric references follow the standard too: a number from 128 to 159 is read the way Windows-1252 does, so &#150; is an en dash, and 0, a surrogate or a value above U+10FFFF becomes the replacement character.

    Decoding happens once. If the result still contains references, such as &amp;lt; becoming &lt;, the text was encoded twice, and a chip tells you so: use Use result as input to decode it again. The text is placed in a detached text box that is never shown on the page and "<" is escaped before decoding, so nothing you paste can run as code.

    Use it with

    Questions

    How do I encode special characters in HTML?

    Paste the text in Encode mode. The five special characters & < > " ' become & < > " and '. Tick the non-ASCII option to encode accented letters and symbols too.

    What is the HTML entity for the copyright symbol?

    © (named), © (decimal) or © (hex). The code point is U+00A9.

    What is the difference between &nbsp; and a space?

      is the no-break space (U+00A0). It is not collapsed with neighbouring spaces and the browser will not wrap a line at it, unlike a normal space.

    Which characters must be escaped in HTML?

    In element text, & and <. In a quoted attribute value, & and the quote character used. Escaping all five of & < > " ' covers every case.

    How do I decode HTML entities?

    Choose Decode and paste the text. Named, decimal and hex references all become characters, and a table lists each one with its code point.

    Does entity encoding prevent XSS?

    Only for text inside HTML element content or a quoted attribute. It does not protect text placed in a script block, a style block or a URL.

    How this page was made: the tool's results are computed in your browser by the code on this page, using the sources listed above; the explanations were drafted with AI help and checked against the tool's own output.