HTML Entity Converter

Encode text into HTML entities, in named (©), decimal (©) or hex (©) form, or decode entities back into plain characters. Encoding works per Unicode code point, so an emoji becomes one valid entity. Decoding uses the browser's HTML parser on an inert document, so it recognizes every named entity in the HTML standard while any tags in the input stay as text and nothing in it can run.

How to use the HTML Entity Converter

  1. Paste text or HTML source into Input.
  2. To encode, pick a style and click Encode. Tick Encode all non-ASCII to turn every character above code point 127 into an entity as well, not just the five HTML specials.
  3. To decode, click Decode. Every entity is replaced by the character it stands for; anything else is left as it is.

The three styles produce different text for the same input. <a href="x">Tom & Jerry</a> in Named style becomes &lt;a href=&quot;x&quot;&gt;Tom &amp; Jerry&lt;/a&gt;. In named style the apostrophe is written &#39;, because &apos; is not defined in HTML 4 and some old parsers reject it. In hex style the same apostrophe is &#x27;.

Without the non-ASCII option, named style still converts the characters it has a short name for (for example © 2026 becomes &copy; 2026), while the numeric styles leave © alone. With the option, decimal turns it into &#169; 2026 and hex turns café into caf&#xE9;.

When HTML entities are needed

An entity is a way to write a character using only ASCII: &, then a name or a number, then ;. Browsers decode it before display, so &lt; shows as <. Entities exist for two reasons.

1. Characters that HTML itself uses. These five must be escaped whenever untrusted text is placed into HTML. Getting this wrong is how most cross-site scripting bugs happen:

  • & → &amp; (always, in text and in attributes)
  • < → &lt; (in text; it starts a tag)
  • > → &gt; (not strictly required, but escaped by convention)
  • " → &quot; (inside double-quoted attribute values)
  • ' → &#39; (inside single-quoted attribute values)

Escaping is context-specific. These entities make text safe inside HTML text and quoted attributes, but not inside a <script> block, a style attribute or a URL such as href="javascript:...". Those need JavaScript, CSS or URL encoding instead.

2. Characters a channel cannot carry. If a system mangles non-ASCII text (an old email pipeline, a database column with the wrong charset, a template engine reading Latin-1), numeric entities let café or € survive as plain ASCII. With UTF-8 end to end, which is the norm today, this is rarely necessary.

Common use cases

  • Showing code on a web page. Encode an HTML snippet so it displays as text inside <pre><code> instead of rendering.
  • Reading escaped data. Decode HTML-escaped strings found in API responses, RSS feeds, scraped pages or database dumps.
  • Debugging double encoding. When a page shows &amp; or &lt; to users, decode once to see what the stored text really is.
  • ASCII-only channels. Turn accented letters, currency symbols and emoji into numeric entities for systems that cannot store UTF-8.

Decoding is one pass, and double encoding shows up

Decoding replaces each entity once, exactly as a browser does. &lt;b&gt; &amp;amp; &#169; &#xA9; &copy; decodes to <b> &amp; © © ©. The &amp;amp; became &amp;, not &, which is the sign of text that was escaped twice. Decode again only if you are sure the data was double-encoded.

Some inputs never decode to what they look like:

  • &#0; and lone surrogate halves such as &#xD83D; are invalid code points. The HTML standard replaces them with U+FFFD, the replacement character (�).
  • An unknown name such as &unknown;, or an ampersand that starts no entity, as in AT&T, is left as it is.
  • Emoji live above U+FFFF. 😀 encodes to &#128512; (decimal) or &#x1F600; (hex). Encoders that walk a JavaScript string unit by unit produce &#55357;&#56832; instead: two surrogate halves that browsers display as two replacement characters. This tool encodes per code point, so emoji survive a round trip.

Frequently asked questions

Named or numeric entities: which should I use?

For the five special characters, either works everywhere. For other characters, numeric entities are the safer choice because every HTML parser understands them, while a named entity only works if the parser knows the name. Named entities are easier for people to read.

Is encoding enough to stop XSS?

Only for HTML text and quoted attribute values. Inside script blocks, event-handler attributes, style attributes or URLs you need JavaScript, CSS or URL escaping, and javascript: URLs must be rejected outright.

Can decoding run code from what I paste?

No. Before decoding, every < in the input is escaped, then the text is parsed with DOMParser into a separate inert document. Tags are kept as literal text and scripts or event handlers never execute.

Why did my emoji turn into two entities with another tool?

JavaScript strings store emoji as two UTF-16 surrogate units. Tools that encode unit by unit emit two numeric entities that are each invalid on their own. This tool encodes the full code point, so 😀 becomes the single decimal entity for code point 128512.

Is my text uploaded?

No. Encoding and decoding run in your browser, and the tool makes no network request with your input.
Embed this tool on your site

Free to embed, no attribution required (but appreciated). Paste this where you want the tool to appear: