DEV

HTML Entity Encoder & Decoder

Escape characters like < > & and quotes so they display safely in HTML, or decode entities back into plain text.

INPUT
OUTPUT

          

How it works

Five characters have special meaning in HTML and must be escaped to show up literally: & becomes &amp;, < becomes &lt;, > becomes &gt;, and the two quote characters become &quot; and &#39;. The optional second mode also converts every non-ASCII character to a numeric entity such as &#233;.

Decoding handles named entities (&copy;), decimal (&#169;) and hex (&#xA9;) forms. Decoded text is only ever shown as text — it is never interpreted as live HTML.

Frequently asked

Why do I need to escape < and & in HTML?

Browsers treat < as the start of a tag and & as the start of an entity, so showing them literally requires escaping. Escaping user-provided text is also a basic defence against HTML injection.

Do I need to encode non-ASCII characters?

Usually not — a page served as UTF-8 displays them correctly. The non-ASCII mode is useful for legacy systems or email templates that can't be trusted to preserve encoding.