Developer tools

HTML Entity Encoder

HTML Entity Encoder & Decoder

Escape text to HTML entities (named, decimal or hex) and decode entities back to characters.

About this tool

About HTML Entity Encoder

Escape text so it shows up literally on a web page instead of being read as markup, or turn a soup of &amp;, &quot; and &#8217; back into the characters they stand for. Choose how much to escape: only the five characters that matter for HTML safety (& < > " '), those plus every non-ASCII character for systems that mangle UTF-8, or every single character, which is a common way to make an email address harder for scrapers to read. Choose how references are written: named entities such as &eacute; and &copy; where a name exists, decimal references like &#233;, or hex references like &#xE9;. The decoder handles all three forms, including every HTML5 named entity, uses U+FFFD for invalid numbers just as browsers do, and lists any names it doesn't recognise rather than silently dropping them. Use it for CMS content, email templates, XML and code samples in documentation. It runs entirely in your browser.

Built and maintained by Abhi JainUpdated

How to Encode HTML Entities

  1. 1

    Choose a direction

    Pick Encode to escape text or Decode to turn entities back into characters.

  2. 2

    Set the options

    When encoding, choose what to Escape (& < > " ' only, + non-ASCII, or Everything) and the Format: Named, Decimal or Hex.

  3. 3

    Paste and copy

    Paste your text or HTML, check the result on the right, then copy or download it.

HTML Entity Encoder: questions and answers

Which characters must be escaped in HTML?

In text content, & and < are the essential ones, and > is escaped by convention. Inside attribute values, also escape the quote character that wraps the value (" or '). Escaping all five covers every case.

What is the difference between &#233; and &eacute;?

None in the result: both produce é. &#233; is a decimal numeric reference to code point 233, &#xE9; is the same number in hex, and &eacute; is a named reference. Numeric references work for every Unicode character; names exist only for some.

Should I use &apos; or &#39;?

&apos; is valid in HTML5 and XML but was not part of HTML 4, so older parsers and some email clients don't recognise it. The encoder writes &#39; (or &#x27;) for the apostrophe, which works everywhere.

Does escaping HTML prevent XSS?

Escaping & < > " ' is the right defence for text placed inside HTML elements and quoted attributes. It is not enough inside <script>, style, URLs or unquoted attributes, which each need their own encoding.

Do I need entities for accented letters?

Not if the page is served as UTF-8, which almost all are. Use the non-ASCII option only for systems that can't handle UTF-8, such as some legacy email or database pipelines.

Ready-made HTML Entity Encoder presets