Skip to content

HTML Entity Encoder & Decoder

Encode text to HTML entities or decode entities back to plain text in your browser. Nothing you paste is sent anywhere.

Runs entirely in your browser. Nothing you paste here is sent to us or anyone else — there is no server processing, no logging of input, and no third-party scripts on this page.

An HTML entity encoder converts characters that have special meaning in HTML — such as <, >, &, and quotes — into safe entity codes like &lt;, and a decoder turns those entities back into the original text. The tool above does both directions in your browser: switch mode, paste your text or markup, and copy the result. Nothing you paste is transmitted anywhere.

What is an HTML entity?

An HTML entity is a short code that stands in for a character the browser would otherwise interpret as part of the page structure. Because < opens a tag and & begins an entity, you cannot simply type them inside content and expect them to appear literally. Entities solve this: &lt; renders as a less-than sign, &amp; renders as an ampersand, and the markup stays intact.

Entities come in two forms. Named entities use a keyword — &copy; for ©, &mdash; for an em dash — and are limited to a fixed list. Numeric entities reference a character by its Unicode code point, in decimal (&#169;) or hexadecimal (&#xA9;), and can represent any character at all.

Which characters need encoding?

Five characters are the essential set. Encoding the ampersand first is critical, because every other entity itself starts with one.

Character Encoded as Why
& &amp; Starts every entity; must be escaped first
< &lt; Opens an HTML tag
> &gt; Closes an HTML tag
&quot; Ends a double-quoted attribute value
&#39; Ends a single-quoted attribute value

A worked example

Say you want to show the text Tom & Jerry <3 inside a page. Typed directly, the browser would try to read <3 as the start of a tag and swallow it. Encoded, it becomes Tom &amp; Jerry &lt;3, which the browser renders back as the exact characters you intended. Paste it into the decoder here and you get the original string returned unchanged.

Common use cases

  • Displaying code on a web page — showing snippets of HTML, XML, or JSX as text rather than having the browser run them.
  • Preventing injection — escaping user-supplied content before it is inserted into a page so it cannot introduce unwanted markup or script.
  • Email and legacy systems — encoding accented letters and symbols as numeric entities so they survive channels restricted to plain ASCII.
  • Debugging — decoding an entity you found in a page or feed to see which character it actually represents.

Common mistakes

  • Double-encoding — encoding already-encoded text turns &amp; into &amp;amp;. If a rendered page shows stray entity codes, decode once to recover.
  • Forgetting attribute quotes — a raw quote inside an attribute value silently ends it early; escape it as &quot; or &#39;.
  • Encoding the ampersand last — do it first, or it will mangle the entities you just created.

When to reach for this tool

Most templating frameworks auto-escape interpolated values, so you seldom encode by hand in application code. This tool is for the gaps: hand-written HTML and email templates, attribute values you assemble as strings, static content, and any time you need to inspect or reverse an entity quickly. Because it uses the browser’s native parser for decoding and a straightforward character map for encoding, the results match exactly what a real browser would produce — and it all runs locally, with nothing you paste ever leaving your device.

Frequently asked questions

What does encoding text to HTML entities do?

It replaces characters that have special meaning in HTML — the ampersand, less-than, greater-than, and both quote marks — with their entity equivalents such as &amp;amp; and &amp;lt;. The browser then displays the literal characters instead of treating them as markup, which is the core defence against broken pages and injected HTML.

Which characters must always be escaped?

At minimum &amp; (&amp;amp;), &lt; (&amp;lt;), &gt; (&amp;gt;), the double quote (&amp;quot;) and the single quote (&amp;#39;). The ampersand must be encoded first, otherwise it would corrupt every other entity you add.

What is the difference between named and numeric entities?

A named entity like &amp;copy; uses a memorable keyword. A numeric entity like &amp;#169; (decimal) or &amp;#xA9; (hexadecimal) refers to the character by its Unicode code point. Numeric entities always work; named entities are limited to a fixed list defined by the HTML standard.

Why would I encode all non-ASCII characters?

Tick the "encode all non-ASCII" option to turn every character above code point 127 — accented letters, symbols, emoji — into a numeric entity. This guarantees the output survives systems or files that are restricted to plain 7-bit ASCII, at the cost of a larger, less readable string.

Is decoding here safe? Does it run the HTML?

Decoding is safe. The tool resolves entities using a detached textarea element, whose contents the browser parses as text and never executes. You get the plain characters back without any script or markup running.

Do I still need to escape output if my framework auto-escapes?

Modern templating engines (Blade, Jinja, JSX, and similar) escape interpolated values by default, so you rarely encode by hand there. This tool is for the cases they miss: raw HTML, email templates, attribute values you build manually, or inspecting what an entity actually represents.

Is my input sent to a server?

No. Encoding and decoding both run entirely in your browser. Nothing you paste is uploaded, logged, or stored, and the tool keeps working with your connection switched off.

Why does my ampersand show as &amp;amp; after encoding?

That is correct. To display a literal ampersand in HTML you must write the entity &amp;amp;. If you are seeing &amp;amp; on a rendered page where you wanted a plain &amp;, your text was encoded one time too many — decode it once to fix the double-encoding.