HTML Entity Encoder / Decoder
Convert special characters like &, <, and > to HTML entities, or decode entities back to plain text.
How to use this tool
Encode turns the five characters that mean something in HTML into entities, so the text displays as written. Decode does the reverse for any entity, named or numeric, such as ©, ₹ or ₹.
Worked example
Encoding <p>Tom & Jerry's "Great" Adventure</p> gives:
<p>Tom & Jerry's "Great" Adventure</p>
Pasted into a page, that shows the tag as text instead of starting a paragraph, which is how code samples and user comments are displayed safely. The apostrophe becomes ' rather than ' because the numeric form also works in old HTML 4 pages and email clients.
Two mistakes to watch for
- Encoding twice. Encoding text that is already encoded turns
&into&amp;, and the page then shows "&" to readers. If you see entity names on a live page, something encoded the text twice; decode once to find the original. - Decoded
isn't a space. It becomes a non-breaking space (U+00A0), which looks identical but fails comparisons such asvalue === "Pune Maharashtra"and isn't matched by a plain space in a search. Replace it with an ordinary space if the text goes into data rather than a page.
Frequently Asked Questions
Do I need to encode ₹, é or emoji?
Not on a page saved as UTF-8 with <meta charset="utf-8">: there those characters can be written directly. Only &, <, > and quotes inside attribute values have to be encoded, and that is all Encode changes. Numeric entities such as ₹ for ₹ are useful when the text must pass through a system that mangles non-ASCII characters.
Does encoding protect against script injection everywhere?
Only in the places where HTML is being parsed: between tags and inside quoted attribute values. Text placed inside a <script> block, a style attribute, an event handler such as onclick, or a URL such as href="javascript:..." needs different escaping or validation, so use your framework's escaping for those contexts.
Is this the same as escaping for JavaScript or URLs?
No. JavaScript strings use backslash escapes (\" and \n), and URLs use percent-encoding (a space becomes %20). Applying HTML entities in those places leaves the text wrong: & inside a URL query is read as the five characters "&" by anything that doesn't parse it as HTML first.
Related Tools
Related Blog Posts
How to Use QR Codes for Marketing, Docs, and Events
How much a QR code can hold, why a shorter or uppercase link gives a code that scans more easily, what error correction actually protects against, and how to size one for print.
Read moreHEX, RGB and HSL: How the Conversions Work and Where They Round
#4F46E5 converted to RGB and HSL step by step, why 89.4% of all colours change when copied as whole-number HSL, why HSL lightness is not brightness (yellow and blue at 50% differ eightfold in contrast), and the alpha that hex can't write exactly.
Read more10 CSS Gradient Ideas You Can Copy and Customize
Ten copy-ready CSS gradients (buttons, dark surfaces, progress bars, stripes, glows, gradient text, photo overlays), plus how gradient angles work and how to avoid the muddy grey middle.
Read more