12 / html-entity-encoder

free online tool

HTML Entity Encoder

Encode and decode HTML entities to prevent XSS and display special characters safely.

Result will appear here...

how to use

  1. 01

    Paste your text into the input field.

  2. 02

    Click 'Encode' to convert special characters to HTML entities, or 'Decode' to reverse.

  3. 03

    Copy the result.

about

What is this tool?

HTML entity encoding converts characters like <, >, &, and " into their safe HTML equivalents (&lt;, &gt;, &amp;, &quot;). This is essential for displaying user-generated content safely in HTML and preventing Cross-Site Scripting (XSS) attacks.

why use this tool

  • -Prevent XSS vulnerabilities when displaying user content.
  • -Display code snippets safely in HTML pages.
  • -Convert encoded HTML back to readable text.
  • -Works entirely in the browser — no server involved.

features

  • -Encodes all standard HTML special characters.
  • -Decodes HTML entities back to plain text.
  • -Handles named and numeric entities.
  • -One-click copy.

comparison

Key HTML Entities Reference

CharacterHTML EntityWhen You Need It
<&lt;Displaying code snippets, angle brackets
>&gt;Closing tags in visible content
&&amp;Ampersands in text (e.g. 'cats & dogs')
"&quot;Attribute values in double-quoted HTML
'&#39;Attribute values in single-quoted HTML
privacy

All processing happens entirely in your browser using JavaScript. No files, text, or data are ever sent to a server. Your data stays on your device.

✦ tip from dragontail

At Dragontail, every piece of user-generated content goes through HTML entity encoding before it touches the DOM — no exceptions. The one time we skipped this step during a prototype, a tester immediately entered a <script> tag in a form field. It didn't cause real harm, but it was a wake-up call. Encode first, ask questions later.

faq

What characters are encoded?

The most important are <, >, &, ", and ' — the characters that have special meaning in HTML.

Does this protect against all XSS attacks?

HTML entity encoding is a crucial defence but not sufficient alone. Always combine with a Content Security Policy and proper input validation.

Is my text sent anywhere?

No. All encoding/decoding happens in your browser.