Skip to content
Developer

HTML Entity Encoder

Encode or decode HTML entities in text.

htmlentityencodedecodeescape
Loading tool…

Recommended tools

Affiliate links — we may earn a commission if you sign up.

About the HTML Entity Encoder

The HTML Entity Encoder escapes and unescapes HTML entities in plain text, covering exactly the five characters that browsers treat as markup — & < > " ' — in either named or numeric form. On the Encode tab a radio group chooses the style: named entities like &amp; and &lt; that stay readable in source, or numeric entities like &#38; and &#60; that work in contexts where named forms are unsupported. Only those five characters are transformed; everything else, including text that already contains entities, passes through untouched. The Decode tab understands hex (&#xe9;), decimal (&#8364;), and a large table of named entities from &nbsp; and &copy; through Greek letters and math symbols, converting them back to real characters. Both tabs have their own Load sample link — one with HTML tags and quotes to escape, one mixing named, hex, and decimal entities to decode. Outputs download as encoded-html.txt or decoded-html.txt. Use it to safely embed code snippets in blog posts, clean up scraped content, or fix text that renders as raw &amp; strings.

Hand-written guide

Examples

Input
<a href="/search?q=core&sons">Tom & Jerry "The Cat's" <b>Meow</b></a>
Output
&lt;a href=&quot;/search?q=core&amp;sons&quot;&gt;Tom &amp; Jerry &quot;The Cat&apos;s&quot; &lt;b&gt;Meow&lt;/b&gt;&lt;/a&gt;
Note: The encode sample under the Named style — only the five markup characters are escaped; the rest of the text passes through unchanged.
Input
5 < 6 & 7 > 4 (Numeric style)
Output
5 &#60; 6 &#38; 7 &#62; 4
Note: Switching the radio to Numeric produces decimal code points instead of named entities, useful where named forms are not recognized.
Input
Tom &amp; Jerry &lt;the cat&apos;s&gt; &quot;meow&quot; &#8212; caf&#xe9; &#8364;5
Output
Tom & Jerry <the cat's> "meow" — café €5
Note: The Decode tab resolves named, decimal, and hex entities — including em dash, accented e, and the euro sign.

How to use

  1. 1

    Open the Encode tab and paste the text you want to escape.

  2. 2

    Pick Named or Numeric with the encoding style radio buttons.

  3. 3

    Copy the encoded result from the Encoded output box, or download it as encoded-html.txt.

  4. 4

    Switch to the Decode tab to turn entities back into characters.

  5. 5

    Use the Load sample links under each tab for realistic starting examples.

Common use cases

  • Escaping code snippets before embedding them in blog posts or CMS content.
  • Decoding scraped HTML entities into normal text for storage or analysis.
  • Preparing text for XML-adjacent contexts where raw angle brackets are invalid.
  • Converting legacy numeric entities in a database into readable characters.
  • Sanitizing display text so user input containing < or & never breaks markup.
  • Checking how a page renders named versus numeric entities in source code.

Best practices

  • Remember the tool escapes only the five markup characters — it is not a full HTML sanitizer and does not strip scripts or attributes.
  • Choose named entities when humans will read the output, numeric when the consumer is XML tooling.
  • Do not double-encode: text already containing &amp; becomes &amp;amp; if you encode it again.
  • Decode before storing into a database when you want normalized text, not markup-ready text.
  • For escaping text inserted into HTML attributes, both styles work, but always quote attribute values too.
  • Review the full decode table output when automated cleaning, since unsupported named entities are left as-is.

Tips

  • Use the Encode tab's sample to see both styles produce equivalent safety for the same input.
  • Decode copied page source before pasting into documentation — it is much more readable without entities.
  • When debugging a double-encoded string, decode twice and compare each intermediate result.
  • Download encoded-html.txt when the escaped output is long, so line breaks are preserved exactly.

Frequently asked questions

Exactly five: & becomes &amp; or &#38;, < becomes &lt; or &#60;, > becomes &gt; or &#62;, double quote becomes &quot; or &#34;, and the apostrophe becomes &apos; or &#39;. Every other character passes through untouched.

Explore more developer tools

Browse the full collection of developer tools on the hub, or jump back to all categories.