HTML Encoder

HTML Encoder / Decoder

Escape `& < > " '` to safe HTML entities, or decode entity-escaped text back to plain. Four encoding levels — Minimal, Named, Numeric, All non-ASCII. UTF-8 + emoji + CJK safe, in your browser.

Default to Minimal — escape only & < > " ', the five characters that break HTML body / attribute contexts. That's what every modern templating engine does. Use Named entities if you want copyright / nbsp / arrows etc. as readable codes (&copy; instead of &#169;). Use Numeric when sending HTML through pipelines that may not understand named entities. Use All non-ASCII when targeting strict ASCII-only systems (legacy email servers, broken APIs).

&apos; is valid in XML and HTML5, but not in HTML 4.01 — older browsers render it as the literal text '. The numeric reference &#39; works everywhere. The decoder accepts &apos; as input for compatibility.

Input
Output

Built for safe HTML output

Escape user content for templates, decode entity-encoded data — and a few small touches that make it actually fun to use.

Four encoding modes

Minimal escapes only the five HTML-unsafe characters (& < > " ') — the right default for normal user-generated content. Named uses readable HTML5 entities like &copy; / &nbsp; / &hearts; where one exists. Numeric encodes every non-ASCII codepoint as &#NN;. All non-ASCII encodes every codepoint outside printable ASCII for legacy / ASCII-only pipelines.

Decode any entity

The decoder handles named entities (&copy;), decimal numeric (&#169;), and hex numeric (&#xA9;). Surrogate-pair codepoints (emoji, ancient scripts) round-trip correctly via UTF-16.

Live preview

Output updates on every keystroke — no Encode / Decode button to press. Switch direction with one click; the Swap button moves output back to input so you can chain transforms.

UTF-8 + emoji + CJK safe

Every Unicode codepoint round-trips: 中文, العربية, русский, हिंदी, 🎉, Þorgeir. Encoder uses per-codepoint iteration (not charAt) so surrogate pairs stay intact.

Privacy by design

Your text stays on your device. Encoder, decoder, named-entity table all run as JavaScript locally. Open DevTools → Network and verify zero outbound requests.

Tiny + fast

Pure JavaScript, no framework runtime. Cold load is under 25 KB gzipped. A 100 KB HTML document encodes in under 5 ms.

How to encode or decode HTML entities

Four steps from raw text to entity-safe output.

  1. 1

    Paste your text

    Drop plain text or HTML into the Input pane. Anything goes — user comments, blog posts, emoji, CJK, RTL scripts. Encoder iterates by codepoint so multi-byte sequences stay intact.

  2. 2

    Pick direction + mode

    Set Direction to Encode (text → entities) or Decode (entities → text). For Encode, pick the mode: Minimal for templates, Named for readable entities, Numeric for non-ASCII as &#NN;, All non-ASCII for ASCII-only output.

  3. 3

    Watch live preview

    Output updates on every keystroke. Compare modes in real time by changing the dropdown. Use Swap to move output back to input — useful for round-trip verification (encode then decode = original).

  4. 4

    Copy or download

    Use the copy icon to push the result to your clipboard, or the download icon to save it as output.encode.html / output.decode.txt. The size diff (chars / bytes in → out) shows exactly how much the encoding inflated or shrank the text.

Built for daily web-dev work

Four common scenarios where a privacy-first browser tool beats pasting code into a random online encoder.

Safely embedding user content into a template

User comments, form responses, search queries — anything coming from outside that ends up inside a <p>, <li>, or attribute. Run through Minimal-mode encode before string-concatenating into your HTML, and you're safe from broken markup and the simplest XSS payloads.

Reading entity-escaped data from an API

Some APIs return strings already entity-escaped (RSS feeds, certain CMS exports, scraped HTML). Paste in, hit Decode, get back the original Unicode. The decoder handles named, decimal, and hex entities including surrogate pairs.

Email subject lines + meta tags

<title>, <meta name="description">, <meta property="og:title"> — all need entity escaping for special characters. Encode your headline once, paste into all three.

Sensitive content that can't go to a third-party service

Internal CMS content, customer data, NDA-protected templates — anything you can't paste into a cloud encoder. The browser-only tool keeps every byte on your laptop. Open DevTools → Network and verify nothing leaves.

100% private — runs in your browser

Your text never leaves your device. Open DevTools → Network and you'll see zero outbound requests during encode or decode.

  • Encoder, decoder, and named-entity lookup table all run as JavaScript on your machine — no server-side conversion, no third-party API.
  • Surrogate-pair codepoints (emoji, ancient scripts) are handled by codepoint iteration, not byte-level mapping — so a paste of 🎉 stays as 🎉 after a round-trip.
  • No login, no telemetry on text content. We only use one cookie for cookie-consent state and one for language preference.

Related guides

Hand-picked reads on HTML escaping, entity tables, and safe templating.

Frequently asked

Which mode should I pick?

Default to Minimal — escape only & < > " ', the five characters that break HTML body / attribute contexts. That's what every modern templating engine does. Use Named entities if you want copyright / nbsp / arrows etc. as readable codes (&copy; instead of &#169;). Use Numeric when sending HTML through pipelines that may not understand named entities. Use All non-ASCII when targeting strict ASCII-only systems (legacy email servers, broken APIs).

Why does this escape `'` as `&#39;` instead of `&apos;`?

&apos; is valid in XML and HTML5, but not in HTML 4.01 — older browsers render it as the literal text '. The numeric reference &#39; works everywhere. The decoder accepts &apos; as input for compatibility.

Will emoji and CJK characters survive?

Yes. The encoder iterates codepoints (not UTF-16 code units), so emoji like 🎉 (U+1F389) become &#127881; on encode and round-trip correctly through decode. Same for CJK (中文 → &#20013;&#25991; in numeric mode).

Is it safe to embed user input directly into HTML after encoding?

For HTML body and attributes — yes, with Minimal mode. For URL contexts (href="...") you also need URL encoding. For inline JavaScript or CSS, neither HTML nor URL encoding is sufficient — use a proper templating engine that understands those contexts. Never paste unescaped user input into a <script> block.

Is anything sent to your server?

No. The encoder, decoder, and named-entity lookup table all run in JavaScript on your device. Open DevTools → Network and you'll see zero outbound requests during encode or decode. Paste secrets, customer data, internal templates — nothing leaves your laptop.