HTML Entity Encoder / Decoder

Encode or decode HTML entities live — escape <, >, & and more for safe markup, or turn entities back into readable text with a plain-text preview.

Ready to encode

Preview (plain text)

When should you encode or decode HTML entities?

What this tool does

This HTML entity encoder and decoder escapes the five characters that break markup — &, <, >, ", and ' — into their entity forms, or reverses the process when you paste entity-heavy content. A plain-text preview shows what decoded output looks like without rendering HTML in the page, so you can verify results safely.

Why you need it

HTML treats angle brackets and ampersands as syntax, not literal text. Paste unescaped <script> into a CMS field and you risk broken layout or worse. Documentation sites, email templates, and blog posts that include code samples depend on entity encoding to display tags as readable characters rather than active elements.

Decoding is equally useful when you inherit content from legacy systems that stored everything as &lt;p&gt;, or when a JSON API returns HTML fragments wrapped in entities. Doing this locally matters when the text contains customer names, internal URLs, or draft copy you do not want on a third-party server.

How to use it

  1. Select Encode to escape plain text, or Decode to convert entities back to characters.
  2. Paste your input into the left textarea — raw HTML snippets, CMS exports, or entity-encoded strings all work.
  3. Check the output panel and the plain-text preview below to confirm the result matches your intent.
  4. Click Copy result, or use Swap to chain encode/decode steps without re-pasting.

Practical examples

  • Code in documentation: Encode if (a < b) before embedding it in a static HTML page so browsers do not interpret the angle brackets as tags.
  • Email templates: Escape ampersands in company names like Smith & Co so mail clients do not truncate the line at the first &.
  • API debugging: Decode a response field that arrives as "Hello" to read the actual string value before logging it.
  • CMS migration: Batch-decode double-encoded entities from an old WordPress export, then re-encode cleanly for a new platform.

How it works

HTML entities are character references that let you represent special symbols using ASCII-safe text. Named entities like &lt; map to the less-than sign; numeric forms like &#60; or &#x3C; achieve the same result and work even when a named alias does not exist. When encoding, this tool replaces each of the five critical characters with its named entity where one is defined (&amp;, &lt;, &gt;, &quot;, &#39;).

Decoding uses the browser’s built-in HTML parser via a temporary textarea element — the same technique many frameworks use internally — which resolves both named and numeric references. The preview panel renders decoded content as plain text inside a <pre> block, so no HTML executes and no scripts run. All processing stays client-side.

Common mistakes

  • Double-encoding: Encoding text that already contains &lt; produces &amp;lt;, which displays literally as &lt; instead of <.
  • Encoding entire documents: Full HTML pages should be sanitized with a proper library, not entity-encoded wholesale — that breaks legitimate tags you intend to keep.
  • Confusing entities with URL encoding: %3C is percent-encoding for URLs; &lt; is for HTML context. Use the right tool for each layer.
  • Assuming all Unicode needs entities: Modern UTF-8 pages can include emoji and accented letters directly. Only escape the five syntax-sensitive characters unless your target system requires more.

FAQ

When should I encode HTML entities?

When displaying user text or code snippets inside HTML so characters like < and & are not treated as markup.

Named vs numeric entities?

Named forms like &amp; are readable. Numeric forms like &#38; work everywhere. This tool prefers named entities when available.

Which characters get encoded?

The five critical characters: ampersand, less-than, greater-than, double quote, and apostrophe. Other Unicode symbols pass through unchanged.

Is decoding safe to preview?

The preview shows decoded text as plain text, not executed HTML, so scripts are not run.

Is my text uploaded to a server?

No. Encoding and decoding run entirely in your browser.

Related tools