HTML Encoder / Decoder — Entities Online

Encode special characters to HTML entities and decode entities back to text online. Handles & < > quotes, named and numeric entities.

—

How it works

Encoding replaces the five HTML-reserved characters: & becomes &amp; (always first, or existing entities get double-encoded), < becomes &lt;, > becomes &gt;, double quotes become &quot; and single quotes become &#39;. Decoding reverses named entities and numeric ones like &#65; or &#x41; back to their characters.

Examples

InputOutput
<p class='x'>Hi</p>&lt;p class=&#39;x&#39;&gt;Hi&lt;/p&gt;
&#72;&#105; &#x41;decodes to: Hi A
&amp;lt;decodes one level to: &lt;

Frequently Asked Questions

Which characters must be encoded in HTML?

At minimum & and < in text content, plus double quotes inside attribute values. Encoding > and single quotes too is harmless and common practice — it keeps templates readable and avoids edge cases in older parsers.

Why is & encoded first?

Because every other entity starts with &. If you encoded < first, the &lt; it produces would then have its & re-encoded into &amp;lt; — showing literally &lt; on the page. Order matters: & always goes first when encoding, last when decoding.

Named or numeric entities — which should I use?

For the five reserved characters both work everywhere (&lt; = &#60;). Named entities are easier to read; numeric ones cover every Unicode point, including characters with no name. This tool decodes both.

Does encoding make untrusted HTML safe to show?

Encoding text makes it display as text instead of markup, which stops injection through that text. It is not a full sanitizer: if you need to allow some tags from users, use a real allowlist sanitizer like DOMPurify instead.

Related Tools

JSON Formatter & ValidatorRandom Password Generator (Bulk)Unix Timestamp Converter (Epoch)CSV to JSON ConverterJSON to YAML ConverterMarkdown to HTML ConverterText to Unicode Converter (Code Points)MD5 Hash GeneratorBase64URL Encoder / DecoderBase64 to PDF ConverterHTML to Markdown Converter