HTML Entity Encode / Decode

Escape special characters into HTML entities or decode them back to plain text.

Runs locallyInstantPrivate
Input
Output
Result appears here.

What This Tool Does

Switch between Encode and Decode mode to convert text in either direction. In Encode mode, the five mandatory HTML special characters — &, <, >, ", and ' — are replaced with their safe entity equivalents so the text can be placed inside HTML without breaking markup. Enable "Encode all non-ASCII" to also convert characters like ©, , and accented letters into numeric entities. In Decode mode, named entities like &amp;, &copy;, and numeric references like &#169; or &#xA9; are converted back to their plain-text equivalents.

When to Encode vs. Decode

  • Encode when you need to display HTML code as text on a web page — for example, in a code block or a tutorial.
  • Encode before inserting user-provided text into an HTML attribute to prevent injection attacks.
  • Decode when you receive HTML-escaped content from an API or database and need to read or edit the original characters.
  • Decode when processing scraped HTML that contains named entities you want as plain Unicode.

Frequently Asked Questions

What is an HTML entity?

An HTML entity is a text string that represents a character in HTML. Entities start with & and end with ;. They are used for characters that have special meaning in HTML (like < and &) or for characters that are hard to type directly (like © for ©). Named entities use a word (e.g., &amp;) while numeric entities use a code point in decimal (&#38;) or hex (&#x26;).

Why do I only need to encode 5 characters?

In UTF-8 encoded HTML5, only five characters have special meaning and must be escaped: & (ampersand), < (less-than), > (greater-than), " (double quote — inside attribute values), and ' (single quote — inside single-quoted attributes). All other Unicode characters can appear as-is in modern HTML.

Does decoding support all named entities?

The decoder covers the most commonly used named entities — the HTML specials, typographic characters (em dash, curly quotes, ellipsis), copyright symbols, and Greek letters. The full HTML5 entity list has over 2,000 entries; very rare named entities may not be decoded and will be left unchanged.

Is my text sent anywhere?

No. All encoding and decoding runs in JavaScript in your browser. Nothing is uploaded.

Related tools