07 / Encoding / html-encoder
HTML Encoder / Decoder
Encode and decode HTML entities.
How to use
- 01Choose Encode or Decode with the Mode switch.
- 02Paste your HTML or text into the Input box; the Output updates as you type.
- 03In Encode mode, tick "Also encode non-ASCII characters" to turn characters such as © or é into numeric entities.
- 04Press Swap ⇄ to move the output into the input and flip the mode, which is a quick way to check a round trip.
- 05Press Copy output to copy the result, or Clear to start over.
What is this tool?
The HTML encoder escapes the characters that have special meaning in HTML (&, <, >, " and ') so text can be shown literally instead of being parsed as markup. The decoder turns named, decimal and hexadecimal entities back into plain characters. Conversion is instant and runs locally in your browser.
Which characters HTML encoding escapes
Five characters can change how a browser parses HTML. Encode mode replaces & with &, < with <, > with >, " with " and ' with '. Everything else is left as-is unless you enable the non-ASCII option, which writes each character above the ASCII range as a decimal numeric entity, for example © becomes ©.
As a worked example, the input <a href="/search?q=a&b"> encodes to <a href="/search?q=a&b">, which a browser displays as the literal tag text instead of rendering a link.
Decoding named and numeric HTML entities
Decode mode uses the browser's own HTML parser, so it understands the full set of named entities (such as , © and é) as well as decimal entities like © and hexadecimal entities like ©. That makes it useful for reading scraped content, CMS exports or API fields that arrive double-escaped.
If a string still contains entities after one decode, it was encoded twice. Press Swap ⇄ twice to feed the output back in and decode it again.
HTML encoding and XSS
Escaping user-controlled text before inserting it into HTML is a core defense against cross-site scripting (XSS). The five-character escape is correct for element content and quoted attribute values. It is not sufficient for other contexts such as JavaScript strings, unquoted attributes or URLs, which need their own escaping rules. Use this tool to craft and inspect test payloads, and rely on your framework's built-in escaping in production code.
A quick QA check: submit a value such as <script>alert(1)</script> through a form, then compare what the page renders with the encoded version from this tool. If the page shows the literal text, the app escaped it; if a dialog appears or the text disappears, the value reached the DOM unescaped.
Common use cases
- Preparing XSS test strings and checking how an app escapes them
- Displaying code samples or raw markup inside documentation pages
- Decoding entity-laden text from scraped pages, RSS feeds or CMS exports
- Spotting double-encoded values such as &amp; in API responses
- Converting non-ASCII characters to numeric entities for legacy systems
FAQ
How do I escape HTML special characters?
Select Encode and paste your text. The tool replaces &, <, >, " and ' with their entities, and you can copy the result with Copy output.
How do I decode HTML entities like & or '?
Select Decode and paste the text. Named, decimal and hexadecimal entities are converted back to plain characters.
What is the difference between " and "?
Both represent a double quote. " is a named entity and " is the equivalent decimal numeric entity; browsers treat them identically.
Does HTML encoding prevent XSS?
It prevents XSS when text is placed in HTML element content or quoted attributes. Other contexts, such as inline JavaScript or URLs, need context-specific escaping.
Is HTML encoding the same as URL encoding?
No. HTML encoding uses entities like < for display in markup, while URL encoding uses percent sequences like %3C for safe use in URLs.