HTML Entity Encoder / Decoder

What Are HTML Entities?

When you display user text inside an HTML page, characters like <, > and & can be misread as tags or entities — breaking the layout or opening XSS risks. Converting them to HTML entities (e.g. < becomes &lt;) keeps the text literal and safe. This free HTML Entity Encoder / Decoder escapes and unescapes those characters instantly in your browser.

An HTML entity is a special code that represents a character that either cannot safely appear in HTML source or would be misinterpreted as markup. The most common examples are &lt; and &gt; for < and >, &amp; for & and &quot; for quotation marks inside attributes. Entities can also represent characters that are hard to type directly, such as non-breaking spaces (&nbsp;), copyright symbols (&copy;) and accented letters from European languages.

How to use it

  1. Choose Encode (text → entities) or Decode (entities → text).
  2. Paste your content — the result updates instantly.
  3. Copy the output into your HTML, template or CMS.

Use Cases

  • Encoding user-generated text before inserting it into an HTML page to prevent cross-site scripting (XSS) attacks.
  • Decoding HTML entities in scraped web content to recover the original readable text.
  • Converting special characters in blog post content or CMS output to their entity equivalents for safe display.
  • Looking up the entity code for a symbol like &copy;, &mdash; or &euro; when writing HTML templates.

How HTML Entity Encoding Works

The encoder replaces the five characters with special meaning in HTML — <, >, &, ' and " — with their named entities: &lt;, &gt;, &amp;, &apos; and &quot;. This is the minimum set required to prevent markup injection. Optionally, extended encoding also replaces non-ASCII characters with their numeric entities (&#nnnn;) for maximum compatibility with older parsers.

Decoding is the reverse: named entities and numeric entities (&amp;#8364; = €) are replaced with their Unicode characters. The tool uses the browser's own HTML parser for decoding by setting innerHTML and reading back textContent — the most reliable approach because it handles all entities the browser understands.

Why use this tool

  • Handles the five HTML-significant characters and numeric entities.
  • Two-way, instant conversion with one-click copy.
  • Private and free — runs entirely in your browser.

Privacy

Encoding and decoding run entirely in your browser. The text you enter is never sent to our servers.

FAQ

Which characters get encoded?

The HTML-significant ones: & < > " and '. Encoding them prevents your text from being interpreted as markup.

Does decoding handle named and numeric entities?

Yes — it decodes named entities like &amp; and numeric ones like &#39; back to their characters.

Is it safe and private?

Yes. Everything runs locally in your browser; nothing is uploaded.

What is the difference between &amp;amp; and &amp;lt; in terms of security?

Both matter for security. &lt; prevents the browser from interpreting text as an HTML tag (blocking tag injection). &amp; prevents double-decoding attacks where &amp;lt; could be decoded twice in a nested context. Always encode both when inserting untrusted text into HTML.