HTML Entity Encoder / Decoder
Convert special characters (like <, >, &) to HTML entities to prevent XSS script executions, or decode them back.
How It Works
- Paste your markup or text in the editor.
- Special characters (&, <, >, ", ') are converted into their corresponding HTML named entities (&, <, >, ", ').
- In decode mode, HTML entities are converted back into raw markup.
Primary Use Cases
- Sanitizing untrusted user inputs before rendering them inside HTML documents to prevent Stored or Reflected XSS.
- Displaying source code snippets cleanly inside web tutorials and markdown pages.
- Decoding entity-encoded payloads found in security incident logs.
Common Security Pitfalls
- Relying solely on HTML entity encoding inside JavaScript execution contexts or HTML attributes without context-aware escaping.
- Encoding already-encoded text, resulting in double-encoded gibberish like &lt;.
Frequently Asked Questions
- How does HTML entity encoding prevent Cross-Site Scripting (XSS)?
- By converting executable tags like <script> into literal text <script>, the browser displays the characters without executing them as code.
- Is HTML entity encoding sufficient for all parts of a webpage?
- No. Encoding requirements change depending on context: HTML body, attributes, JavaScript variables, CSS, and URLs each require specialized escaping.
References & Standards