HTML Entity Encoder and Decoder: Escape and Unescape HTML Online

Escape characters like < > & and quote marks so text shows up safely in a web page, or unescape codes like &copy; and &#8364; back into the symbols they stand for.

  • Named, decimal and hex
  • Understands 2,000+ entity names
  • Instant and private

How to use the HTML Entity Encoder tool

  1. Paste the contentAdd plain text you want to make HTML-safe, or markup littered with entity codes.
  2. Pick a directionEncode converts risky characters into entities; Decode turns entity codes back into characters.
  3. Choose how much to escapeHandle just the five reserved HTML characters, or also convert accented letters and symbols into named, decimal or hex codes.
  4. Grab the outputCopy it, or press “Use result as input” to run the reverse conversion.

HTML entity tool features

  • Reserved characters escapedAmpersands, angle brackets and both quote marks are converted, so user content can’t break your markup.
  • Pick the entity styleWrite non-ASCII characters as names (&copy;), decimal numbers (&#169;) or hex numbers (&#xA9;).
  • Full entity decodingDecoding uses the browser’s own HTML parser, so every named entity in the spec is understood.
  • Emoji handled properlyCharacters beyond the basic plane, emoji included, become one correct numeric entity.
  • Visible repeated spacesOptionally preserve double spaces by inserting &nbsp;.

What are HTML entities?

A few characters are reserved in HTML: a less-than sign opens a tag and an ampersand opens an entity, so typing them straight into content can break a page or open a security hole. Entities are short codes that stand in for those characters safely. Writing &lt; shows a less-than sign, and &amp; shows an ampersand. They also cover symbols that are awkward to type, like ™ or ₹.

Characters you must always escape

  • The ampersand becomes &amp;, because every entity begins with one.
  • The less-than sign becomes &lt;, because it opens a tag.
  • The greater-than sign becomes &gt;, because it closes a tag.
  • The double quote becomes &quot;, because it ends double-quoted attribute values.
  • The apostrophe becomes &#39;, because it ends single-quoted attribute values.

Frequently used HTML entities

  • Non-breaking space: &nbsp; or &#160;
  • Copyright sign: &copy; or &#169;
  • Registered trademark: &reg; or &#174;
  • Trademark: &trade; or &#8482;
  • Euro and pound signs: &euro; / &#8364; and &pound; / &#163;
  • Em dash and ellipsis: &mdash; / &#8212; and &hellip; / &#8230;
  • Curly double quotes: &ldquo; &rdquo; or &#8220; &#8221;

Are entities still needed for accents and symbols?

Mostly not. Today’s pages are saved as UTF-8 and declare <meta charset="utf-8">, so characters such as ü, ç, ₹ and emoji can be typed directly. Numeric or named codes for non-ASCII characters mainly help with legacy systems, email templates, XML that has to stay pure ASCII, or files whose encoding you can’t guarantee. The five reserved characters above, though, must always be escaped in text and attributes.

Escaping and XSS security

Escaping user-supplied text before putting it into HTML is a core defence against cross-site scripting (XSS). In production apps, let your template engine handle it automatically, for example Laravel Blade’s {{ }}, React’s JSX or Django templates. To make text safe for URLs instead, use the URL Encoder & Decoder, and for binary data the Base64 Encoder.

Frequently asked questions

What does HTML encoding do?
It swaps characters that HTML treats specially, like < and &, for entities such as &lt; and &amp;, so they show as text rather than being parsed as code.
How can I decode HTML entities?
Paste the text and press Decode; codes such as &amp;, &copy; and &#8364; turn back into &, © and €.
What’s the difference between named and numeric entities?
Named entities use a word, like &copy;, while numeric ones use the Unicode code point in decimal (&#169;) or hex (&#xA9;). They all render identically.
What does &amp;nbsp; mean?
It’s a non-breaking space, which keeps two words on one line and isn’t collapsed when several spaces appear together.
Does my code get uploaded?
No. Encoding and decoding happen entirely in your browser.