Avexora Tools

HTML Entity Encoder / Decoder

Free HTML entity encoder and decoder. Escape <, >, & and quotes for safe HTML display, or decode named and numeric entities back into readable text.

About the HTML Entity Encoder / Decoder

An HTML entity encoder/decoder that escapes special characters (like <, >, &) for safe rendering in HTML, and decodes entity-riddled text back into readable characters.

This tool encodes text for safe embedding in HTML, and decodes entity-riddled text back to readable characters. HTML gives special meaning to a handful of characters: < opens a tag, & starts an entity, quotes delimit attributes. Put raw user text or code containing those characters into a page and the browser misreads it — content disappears into imaginary tags, layouts break, and in the worst case injected script runs. The fix is entity encoding: < becomes &lt;, & becomes &amp;, and the browser displays the characters instead of interpreting them.

Encoding here covers the five structurally dangerous characters (&, <, >, double and single quotes) plus any character outside printable ASCII, which is emitted as a numeric entity — handy when your file might travel through systems that mangle UTF-8. Decoding understands the common named entities (&amp;, &lt;, &gt;, &quot;, &apos;, &nbsp;) as well as decimal (&#8377;) and hex (&#x20B9;) numeric forms, so text copied out of HTML source, RSS feeds or scraped pages turns back into normal prose.

Everyday jobs: embedding a code snippet in a blog post so if (a < b) displays literally; putting a company name like "R&D Labs" into an HTML attribute; cleaning up an exported document where every rupee sign arrived as &#8377;. One caution — entity encoding output is for HTML contexts. It is not sufficient escaping for JavaScript strings, URLs or SQL; each context has its own rules (the URL encoder next door handles that case).

How to use the HTML Entity Encoder / Decoder

  1. Paste your text or HTML code into the input area.
  2. Select 'Encode' to escape special characters for HTML, or 'Decode' to revert entities back to text.
  3. Click Convert.
  4. Copy the processed output.

Worked example

Encoding `if (a < b && c > d)` results in `if (a &lt; b &amp;&amp; c &gt; d)`. Decoding the latter returns the original code.

Frequently asked questions

Which characters must be escaped in HTML?
At minimum & and < in content, plus quotes inside attribute values. This encoder handles all five dangerous characters and non-ASCII text, which is always safe to over-escape.
What's the difference between &#8377; and &#x20B9;?
The same character (₹) referenced by decimal vs hexadecimal code point. Both are valid; the decoder accepts both plus common named entities.
Does encoding protect against XSS?
Entity-encoding untrusted text before inserting it into HTML content is a core XSS defence, but the escaping must match the context — attribute, URL and JavaScript contexts each need their own rules. Use a templating engine's auto-escaping where possible.
Does decoding handle named entities like &nbsp;?
Yes, the decoder supports common named entities like &nbsp; (non-breaking space), &copy; (copyright), as well as numeric and hex entities.
Should I encode text before saving it to a database?
Usually, no. It's best practice to store data in its raw, unencoded form in the database, and only encode it when rendering it into an HTML template.

More from Avexora

All Avexora products →

Business software from the team behind these free tools.

Get one practical business tip every week

Tools, templates and tactics for running your business — free, no spam.

Related tools

More developer & web utilities