Skip to content

HTML Entity Encoder

Escape special characters for HTML, or decode entities.

How to use the HTML entity encoder

Three steps, all in your browser.

  1. 1

    Paste your input

    Type or paste your code or data. Press Sample to try an example.

  2. 2

    Choose the direction

    Encode or decode. Errors point at what's wrong with the input.

  3. 3

    Copy the result

    Copy the output in one click. Nothing is saved or sent anywhere.

HTML Entity Encoder: what to know

The HTML entity encoder escapes text so it displays as text in HTML instead of being read as markup: < becomes &lt;, > becomes &gt;, & becomes &amp; and quotes become &quot; and &#39;. The decoder does the reverse, turning named entities (&copy;, &nbsp;), decimal (&#169;) and hexadecimal (&#xA9;) references back into characters.

Escaping is how you show code samples on a web page and how templates keep user input from turning into tags. It's an important defense against cross-site scripting (XSS) when text is placed between tags or inside a quoted attribute. It isn't enough in other contexts, such as inside a script, a style or a URL attribute like href, which need their own escaping or validation.

In a page saved as UTF-8, which is nearly all of them, you don't need entities for accented letters, symbols or emoji: they can be written directly. Entities remain useful for invisible or ambiguous characters such as &nbsp; (a non-breaking space) and &shy; (a soft hyphen).

Popular uses

  • Showing HTML or XML code samples on a web page
  • Decoding entities in scraped or exported content
  • Escaping text for HTML attributes and templates
  • Cleaning &amp;amp; double-encoding bugs

Tips for the best result

  • &amp;amp; in your output means text was escaped twice; decode once and check where the first escape happens.
  • Let your template engine or framework escape by default rather than escaping by hand.
  • The HTML entities reference page lists common named entities with their codes.

Read how JustYourDev works and our privacy details. Code, data and files you use here are processed in your browser and are never sent to our server.

Frequently asked questions

& and < in text, and the quote character used around an attribute value (" or '). Escaping > as well is common and harmless. Everything else can be written as is in a UTF-8 page.

Escaping text placed between tags and inside quoted attributes is a key part of preventing cross-site scripting, but it isn't enough on its own in URLs, scripts or styles. Use your framework's escaping, which does it in context.

No. Every tool runs in your browser, so your code, tokens, keys and files are processed on your device and are not sent to our server or stored. Reloading or closing the page clears them.

Yes. Every tool is free with no sign-up and no limits on use. Clearly labeled ads keep it that way.

Yes. The tools work in any modern browser on phones, tablets and computers, though large files and long code are easier to handle on a computer.