HTML Entity Encoder / Decoder
Encode special characters to HTML entities or decode them back — Encode mode reliably handles the 5 core characters (< > & " '), and both previously-confirmed gaps are now fixed: the "Encode quotes" checkbox now genuinely controls whether quotes are encoded, and a new "Encode all non-ASCII characters" option now converts characters like ©, €, curly quotes, and em dashes into their proper named HTML entities. Decode mode remains broad, correctly handling about 30 common named entities plus any numeric entity.
How to Use This Tool
Select encode or decode mode.
Select encode or decode mode.
Type or paste text into the input area.
Type or paste text into the input area.
Pro Tip
Watch for double-encoding, one of the most common HTML entity bugs: running an already-encoded string through the encoder again turns & into &amp;, which then displays literally as '&' on the page instead of a clean ampersand. Always decode first to check the current state before re-encoding. If your source text has copyright symbols, curly quotes, or em dashes that need to become HTML entities, check "Encode all non-ASCII characters" — that conversion now genuinely works.
About This Tool
When to Use
- Encoding a code sample containing < and > characters so it displays as literal text inside a <pre> block instead of being parsed as HTML.
- Decoding HTML entities from a CMS export to recover the original readable text before reprocessing it.
- Preparing user-submitted comment text for safe display by encoding any embedded angle brackets or ampersands, using "Encode quotes" off if the display context genuinely doesn't need quotes escaped.
Key Details
An HTML entity encoder and decoder converts special characters like <, >, &, and quotes into their named or numeric HTML entities (<, >, &, ") and back again, preventing browsers from m...
Worked example
Encoding <script>alert('hi')</script> produces <script>alert('hi')</script> — the browser now displays the literal text of the tag instead of executing it as JavaScript, which is exactly the escaping needed when rendering untrusted user input safely inside a page. Encoding a string containing a copyright symbol, like Made with © 2024, with "Encode all non-ASCII characters" checked now correctly produces Made with © 2024 — the readable named entity, not just a numeric fallback — whereas leaving that option unchecked (the default) still passes © through unconverted, exactly matching the tool's core 5-character scope.
Interpreting your result
An encoded result that leaves accented letters, currency symbols, dashes, or curly quotes untouched with "Encode all non-ASCII characters" unchecked is expected default behavior, not a mistake — only < > & " ' convert by default. Check that option to convert everything else too. The "Entities encoded" and "Encodable chars found" counts now correctly reflect whichever set of characters is actually being converted, including the broader set when "Encode all" is on. Checking or unchecking "Encode quotes" now genuinely changes the output — trust it.
HTML Entity Encoder / Decoder FAQ
What are HTML entities?
HTML entities are special codes that represent characters that have special meaning in HTML (< > & " ') or characters that are not easily typed on a keyboard (© → ©, € → €). They start with & and end with ;. Decode mode correctly converts both kinds back to their original characters; Encode mode always produces entities for the first group, and now genuinely produces them for the second group too when "Encode all non-ASCII characters" is checked.
Why do I need to encode HTML entities?
Encoding HTML entities prevents XSS (Cross-Site Scripting) attacks when displaying user-generated content, ensures HTML renders correctly when it shouldn't be interpreted as markup, and allows special characters to display properly in HTML documents.
What is the difference between named and numeric entities?
Named entities use descriptive names like & (&), < (<), © (©). Numeric entities use decimal (©) or hexadecimal (©) character codes. Named entities are easier to read; numeric entities cover every Unicode character. Decode mode handles both correctly (around 30 common named entities, plus any numeric entity). With "Encode all non-ASCII characters" checked, Encode mode now genuinely generates a named entity for any of those ~30 common characters (©, €, curly quotes, em/en dashes, etc.) and falls back to a numeric entity for anything else non-ASCII.
Is the "Encode quotes" checkbox reliable?
Yes, now genuinely — this was previously a confirmed dead control: toggling it changed nothing, since its value never actually reached the encoding function and quotes were always converted regardless of the checkbox's state. That's fixed: unchecking it now genuinely leaves " and ' as literal characters in the encoded output instead of converting them to "/'.
What does the encodeAll option do, and how do I turn it on?
Check "Encode all non-ASCII characters" in Encode mode — this was previously a confirmed unreachable feature (the capability existed in the underlying code, but no checkbox or toggle anywhere in the interface exposed it, so it was permanently off with no way to enable it). That's fixed: checking it now genuinely encodes every non-ASCII character, using the matching named entity (©, €, —, curly quotes, and about 20 others) where one exists, and a numeric entity for anything else.
What is the difference between HTML encoding and CSS escaping?
HTML encoding and CSS escaping are separate mechanisms for different contexts. HTML encoding replaces characters like <, >, &, and quotes with <, >, &, " for safe HTML output. CSS escaping uses a backslash prefix (\) to escape special characters in CSS selectors, property values, or content strings. Never mix them — use HTML encoding for HTML contexts and CSS.escape() for CSS contexts.
Master Your Entire Toolkit
Access 500+ specialized calculators and tools designed for precision. No sign-up required, 100% free.
Built and reviewed by the Toolzip Team · Based on HTML Living Standard — Named Character References