Encoding

HTML Entity Encoder & Decoder

Convert <, >, &, quotes and optionally non-ASCII characters to HTML entities, or decode named and numeric entities back to text.

Guide: HTML Entities: Escape, Encode and Decode Safely

Ready.

What it does

HTML gives special meaning to <, >, & and quotes. To show these characters as text, write them as entities such as &lt; and &amp;. Escaping user-provided text this way is a basic defence against injecting markup into a page.

How to use

  1. Choose Encode or Decode and paste your text.
  2. Encoding escapes & < > " '. Tick "Also encode non-ASCII" to turn every character above U+007F into a numeric entity such as &#233;.
  3. Decoding understands named entities (&copy;, &euro;...) and numeric ones (&#8364;, &#x20AC;).

Example

<p>Tom & Jerry's "show"</p> encodes to &lt;p&gt;Tom &amp; Jerry&#39;s &quot;show&quot;&lt;/p&gt;. With "Also encode non-ASCII" ticked, café € becomes caf&#233; &#8364; and an emoji becomes a single numeric entity such as &#128512;. Swap moves the output back into the input and flips the mode, which is a quick way to check that a round trip returns the original.

Decoding details

  • Decoding uses the browser's own HTML rules, so &amp;lt; decodes once to &lt;, and a few legacy entities such as &copy work without the semicolon.
  • Unknown names such as &unknown; are left as they are. Impossible numbers like &#0; or &#x110000; become the replacement character, and numbers 128 to 159 follow the HTML table for Windows-1252, so &#128; is the euro sign.
  • &nbsp; decodes to a non-breaking space, which looks like an ordinary space but is a different character.
  • Markup in the input is not interpreted or run: decoding returns text only.

Where escaping is enough

Escaping the five characters protects text content and quoted attribute values. It does not make a value safe inside a <script> block, a style block, an unquoted attribute or a URL; those contexts need their own escaping, such as URL percent-encoding for links or string escaping for JavaScript and JSON strings. To look up the code of a character, use the ASCII Table; to turn Markdown into HTML, see the Markdown ↔ HTML Converter; and to tidy the resulting markup, use the HTML Formatter.

More examples

With “Also encode non-ASCII” switched on, café €5 <b> becomes:

caf&#233; &#8364;5 &lt;b&gt;

Decoding understands named, decimal and hexadecimal entities. The input &copy; 2026 &euro;5 &#8364; &#x20AC; &nbsp;x &unknown; &amp;lt; gives:

© 2026 €5 € €  x &unknown; &lt;
  • &nbsp; becomes a non-breaking space, which looks like a normal space but is a different character.
  • An unknown name such as &unknown; is left as it is instead of being guessed.
  • &amp;lt; is decoded exactly once and gives &lt;. This is how double escaping shows up: text that was escaped twice needs two decoding passes.

Entities are not a complete defence

Escaping the five characters is the right way to put untrusted text between HTML tags. It is not enough everywhere: values inside script elements, unquoted attributes, URLs and CSS need their own escaping. For those, use the String Escape and Unescape tool, which has a separate mode for each context.

Frequently asked questions

Which characters does Encode change?

The ampersand, less-than and greater-than signs and the two kinds of quotation mark: & < > " and the apostrophe.

When should I encode non-ASCII characters?

Mostly when the page cannot be served as UTF-8. With UTF-8, which is the default today, accented letters, symbols and emoji can be written directly.

Is my text uploaded?

No. Encoding and decoding run in your browser.

Privacy

This tool runs entirely in your browser. What you enter is processed on your device and is not sent to a server.

Share this tool

Your data is not included in this link.