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.
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: &lt; decodes to the text <, 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.
Four are non-negotiable in text: & (&), < (<), > (> in practice), and the quote character that delimits any attribute the text sits inside — " (") in double-quoted attributes, ' (') 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.
Why does &lt; display as < on a page but decode to < here?
Because decoding is a single pass. & is the entity for &, so &lt; decodes to the literal text < — 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.