simpletool.io

HTML Encoder/Decoder

Escape and unescape HTML entities in any string.

Encoding and decoding run in your browser. Nothing you paste is sent to a server.

Raw HTML / text

Output

90 characters

What is an HTML Encoder / Decoder?

HTML encoding — also called entity escaping — converts characters that have special meaning in HTML markup (<, >, &, ",') into their entity equivalents (&lt;, &gt;,&amp;, &quot;, &#39;). The browser then renders them as the literal characters rather than interpreting them as HTML markup. This is the single most important defence against cross-site scripting (XSS) when you have user-supplied content that needs to appear on a page without being treated as code.

There are three common encoding levels. Minimal handles just the five unsafe characters — the bare minimum to prevent markup confusion. Modern web frameworks (React, Vue, Svelte, Angular, Django, Rails) all perform this level automatically on template output. Named entities adds friendly aliases for the common symbols — &copy; for ©, &trade; for ™, &nbsp; for a non-breaking space. The result is human-readable and survives copy-paste between editors.Numeric (all non-ASCII) encodes every character above the basic ASCII range as a numeric reference like &#233;. It is the safest choice when you do not know what encoding the consumer will use, because every character above 0x7F becomes an unambiguous decimal code point.

Decoding is the inverse — turning entities back into the characters they represent. The trick with decoding is that HTML has thousands of named entities, and rolling your own table is a maintenance burden. The tool uses the browser's own HTML parser: we create a hidden textarea, set its innerHTML to the encoded string, and read back thevalue. The browser handles every entity correctly, including rare ones like &frac34; (¾) and decimal/hex numeric references (&#9731;, &#x2603;).

Developers reach for an HTML encoder in several scenarios. When a CMS exports content that will be embedded in an email template that treats angle brackets as markup. When a code tutorial needs to show HTML source without the browser rendering it. When pasting output from an older system that has already encoded the content and you need to reverse that. When preparing JavaScript string literals that contain HTML.

A common trap: HTML encoding is not a substitute for proper output escaping in dynamic code. React's JSX, Vue's templates, and Django's template language all encode variables automatically when you interpolate them into markup. Only use this tool for one-off conversions (content migrations, tutorials, debugging). In an app, rely on the framework's built-in escaping and never hand-encode strings yourself — the framework knows more about the context than you do.

How to use the HTML Encoder / Decoder

  1. Pick encode or decode. Tabs at the top flip the direction.
  2. Choose encoding level. Minimal, named entities, or numeric for everything non-ASCII.
  3. Paste the input. Raw HTML or text for encoding, entity-containing HTML for decoding.
  4. Copy the output. The result is ready to paste into an email template, a tutorial, or a code file.
  5. Swap and verify. Feed the output back in to confirm the conversion is reversible.

Features

  • Three encoding levels: minimal, named entities, full numeric.
  • Decoder uses the browser's own parser — handles every named and numeric entity.
  • Encodes emoji and non-Latin scripts correctly under the numeric option.
  • Swap button to round-trip input and output.
  • Runs entirely in your browser.

Frequently asked questions

Which characters need HTML encoding?
The absolute minimum is < > & " '. Inside script or style blocks there are additional concerns. Outside of those blocks, those five characters are enough to prevent markup injection. For user-supplied content, encoding these five prevents cross-site scripting.
What's the difference between named and numeric entities?
Named entities use friendly aliases (&copy;, &trade;, &nbsp;). Numeric references use code points (&#169;, &#8482;, &#160;). Named entities are more readable; numeric references work everywhere and don't depend on the consumer knowing the name table.
Do I need to HTML-encode in React / Vue / modern frameworks?
No. Template variables are auto-escaped. You only need manual encoding for edge cases: dangerouslySetInnerHTML, v-html, raw Django template filters, or when preparing content for an email or export that expects escaped HTML.
How do I encode all non-ASCII characters?
Pick the 'Numeric (all non-ASCII)' level. Every character above 0x7F becomes a decimal numeric reference like &#233;. This is the safest choice when you don't know what encoding the consumer uses.
Is there a list of all HTML entities?
Yes — the W3C maintains a full entity table at https://html.spec.whatwg.org/multipage/named-characters.html. Our decoder handles every entity in that list because it relies on the browser's own parser.