KKwikfig.

HTML Entity Encoder / Decoder

Encode special characters as named or numeric HTML entities and decode entities back to text, with a reference table of the entities you will actually meet. Runs entirely in your browser — your numbers never leave this device.

Mode
Variant
Input
Output

How it works

Named mode: character → &name; ( < becomes &lt;, © becomes &copy; ) | Numeric mode: character → &#N; where N is the decimal code point ( © becomes &#169; ) | Decoding reverses both forms; the hexadecimal form &#xH; reads H in base 16 ( ✓ is &#x2713; and &#10003; )
Common HTML entities — the characters this table's rows are drawn from
CharacterNamed entityNumeric (decimal)
&&amp;&#38;
<&lt;&#60;
>&gt;&#62;
"&quot;&#34;
'&apos;&#39;
©&copy;&#169;
®&reg;&#174;
™&trade;&#8482;
€&euro;&#8364;
£&pound;&#163;
—&mdash;&#8212;
…&hellip;&#8230;
×&times;&#215;
✓&check;&#10003;
°&deg;&#176;

HTML reserves a handful of characters — < and > build tags, & starts an entity, quotes delimit attributes — so any of them appearing as ordinary text must be written as an entity, a stand-in the browser swaps back when it renders. This tool writes those stand-ins in two modes. Named mode uses the readable entities where they exist (&lt;, &amp;, &copy;) and falls back to numbers for characters that have no name in its table. Numeric mode writes every special or non-ASCII character as its decimal code point (&#169;), which needs no name table at all and works in XML just as it does in HTML.

Decoding runs in reverse and handles all three spellings — named, decimal and hexadecimal — in a single pass, leaving anything it does not recognise exactly as written: &unknown; comes back as &unknown;, not as a guess. That one-pass rule matters, because it prevents the double-decode trap: &amp;lt; decodes to the text &lt;, which a page would display as < — decoding it a second time in your code would turn displayed text into a real tag opener.

Reach for encoding whenever text is inserted into markup and must stay text — user comments, code samples, prices with currency symbols in attributes. And note what entities are not: they are a display encoding, not a sanitiser. Encoding your own text is how you show it safely; it does not make untrusted markup safe to insert. All conversion runs in your browser, and pasted text is never uploaded.

Worked examples

Encoding markup characters as named entities

Input
Text = a < b & ©, Mode = named
Working
The < becomes &lt; so a browser shows it instead of opening a tag, the & becomes &amp;, and © takes its named entity &copy;. Ordinary letters and spaces pass through untouched.
Result
a &lt; b &amp; &copy;

The same idea in numeric mode

Input
Text = © 2026, Mode = numeric
Working
© has code point 169, so numeric mode writes &#169;. The digits and the letters of 2026 are plain ASCII text and need no encoding in either mode.
Result
&#169; 2026

Decoding a mixed string back to text

Input
Text = &lt;p&gt; &amp; &#169; &#x2713;
Working
Named, decimal and hexadecimal entities are all read in one pass: &lt; and &gt; give the angle brackets, &amp; gives &, &#169; gives ©, and the hex form &#x2713; gives ✓.
Result
<p> & © ✓

Frequently asked questions

Which characters must be encoded in HTML?

Four are non-negotiable in text: & (&amp;), < (&lt;), > (&gt; in practice), and the quote character that delimits any attribute the text sits inside — " (&quot;) in double-quoted attributes, ' (&apos;) in single-quoted ones. A raw & is the sneakiest, because browsers try to read what follows it as an entity and can swallow characters when it almost matches one.

Named or numeric — which should I use?

Named entities are easier to read and audit in source (&copy; says what it means), so prefer them in HTML you maintain. Numeric entities need no name to exist — every character has a code point — so they are the fallback for rare symbols, and the only choice in strict XML, which predefines just five names (&amp;, &lt;, &gt;, &quot;, &apos;). Both forms render identically.

Why does &amp;lt; display as < on a page but decode to &lt; here?

Because decoding is a single pass. &amp; is the entity for &, so &amp;lt; decodes to the literal text &lt; — and when that text is placed in a page as already-encoded content, the browser displays it as <. Decoding twice would manufacture a real < out of text that was deliberately shown, which is how double-decoding bugs turn text into markup.

What happens to an entity the decoder does not know?

It is left exactly as written. &unknown; decodes to &unknown;, unchanged — inventing a replacement would corrupt text that may be perfectly meaningful in a fuller HTML entity set than the common table this tool carries. Unknown entities in a browser are likewise shown literally.

Does encoding HTML entities make untrusted content safe?

No. Encoding is how you display your own text inside markup without it being read as markup. It is not sanitisation: if you insert someone else's raw HTML into a page, entities do not neutralise scripts or event handlers embedded in it. Keep the jobs separate — encode text you print, sanitise markup you accept, with a dedicated library for the second.

Is my text sent anywhere?

No. Encoding and decoding run in your browser only — nothing you paste is uploaded, stored or tracked.

Related tools

More in Developer Tools · Browse all tools