HTML Encode/Decode

Escape special characters to HTML entities so code and user input display safely, or decode entities back to text. Runs entirely in your browser.

The five HTML special characters

CharacterNamed entityNumeric
&&&
<&lt;&#60;
>&gt;&#62;
"&quot;&#34;
'&#39;&#39;

What HTML encoding is for

HTML gives a handful of characters structural power. A < starts a tag, an & starts an entity, and quotes delimit attribute values. To show those characters as literal text - a snippet of code in a tutorial, a maths expression, or anything a user typed - you replace them with entities so the browser prints them instead of interpreting them. Decoding does the reverse, turning entities back into the raw characters.

Encode the ampersand first

Order matters. Because every entity itself begins with an ampersand, you must escape & to &amp; before you touch the angle brackets - otherwise encoding < to &lt; and then re-encoding the ampersand would produce a mangled &amp;lt;. This tool always encodes in the correct order, so Tom & Jerry <3 becomes Tom &amp; Jerry &lt;3 exactly once.

Named versus numeric, and non-ASCII

For the five core characters this tool emits the widely supported named entities (plus a numeric one for the apostrophe, whose &apos; name is not valid in old HTML). Tick encode non-ASCII characters to also convert accents, symbols and emoji: common ones such as the copyright sign and non-breaking space use their named entities, and everything else falls back to a numeric &#NNN; reference. Leave it off for modern UTF-8 pages, where those characters are perfectly safe as-is.

Escaping user input like this is the front line against cross-site scripting. For other developer needs, reach for the URL encoder when a value goes into a link, the Base64 encoder for binary-safe transport, or the JSON formatter to tidy API data.

Frequently asked questions

Which characters need to be HTML-encoded?
The five that carry meaning in HTML: & (&amp;amp;), < (&amp;lt;), > (&amp;gt;), " (&amp;quot;) and ' (&amp;#39;). Encoding the ampersand first, then the angle brackets, stops the browser treating your text as markup. Quotes matter inside attribute values.
What is the difference between named and numeric entities?
A named entity like &amp;copy; is a human-readable alias; a numeric entity like &amp;#169; refers to the character by its Unicode code point. Both render identically. Named entities are easier to read but only exist for a fixed set of characters, so numeric entities are the universal fallback.
Why should I encode user input before showing it on a page?
If you drop raw user text into a page, a value containing <script> or an onclick attribute can execute in your visitors' browsers - a cross-site scripting (XSS) attack. Encoding the special characters turns that markup into harmless visible text. It is a core defence for any site that echoes user content.
Do I need to encode every non-English character?
No. If your page is served as UTF-8 (the modern default), characters like accents, emoji and non-Latin scripts display fine as-is. Encoding them to entities is optional and only useful for legacy systems or ASCII-only channels - which is why it is a checkbox here, off by default.