Skip to main content

Free HTML Entity Encoder & Decoder Online

Convert any text to safe HTML entities — or decode entity-laden HTML back to plain characters. Three encode modes (dangerous-five, named, numeric), decimal or hex output, full Unicode support. 100% client-side.

Try a Sample

Bidirectional in One Click

Encode plain text to entities, decode entities back to characters. Toggle direction without losing your input. No copy-paste round-tripping.

XSS-Safe Encoding

"Dangerous Five" mode encodes only `& < > " '` — the minimum-required set to safely embed user content in HTML body and attribute contexts. No data loss, no overzealous mangling.

Full Unicode

Surrogate-pair safe, emoji safe. Iteration is per code point (not per UTF-16 code unit), so `👋` encodes as a single `&#128075;` entity, not as two broken halves.

100% Client-Side

Encoding, decoding, and entity-table lookup all run in your browser. User submissions, leaked credentials, or pre-sanitized payloads — none of it leaves your device.

The XSS-Safe HTML Entity Encoder for Modern Web Apps

HTML entities are the oldest, most reliable layer of XSS defence. Encoding the five dangerous characters (& < > " ') before inserting user content into HTML body or attribute contexts prevents browsers from interpreting that content as markup — and stops the entire class of stored and reflected XSS attacks that have plagued the web since the 1990s. Our Free Online HTML Entity Encoder & Decoder implements this correctly, surrogate-pair-safe, with four encode modes and decimal/hex numeric formats — all offline.

Pair this converter with our URL Encoder/Decoder (percent-encoding for URL-context strings is a different problem with overlapping output), the HTML Formatter (to pretty-print the encoded result), and the Base64 Encoder (when your context is JSON or HTTP headers, not HTML).

The Dangerous Five: HTML's Required Encodings

CharacterNamed EntityDecimalHexWhy It's Required
&&amp;&#38;&#x26;Starts every other entity — must be encoded first
<&lt;&#60;&#x3C;Starts a tag — un-encoded enables tag injection
>&gt;&#62;&#x3E;Closes a tag — pairs with < for full injection
"&quot;&#34;&#x22;Breaks out of double-quoted attribute values
'&apos;&#39;&#x27;Breaks out of single-quoted attribute values

Context-Aware Encoding (Where HTML Entities Fit)

HTML entities solve the HTML-context problem only. Other contexts have their own escape rules:

HTML Body / Attribute

HTML-encode the dangerous five. THIS tool. &lt;script&gt;

URL Path / Query String

Percent-encode via URL Encoder. %3Cscript%3E

JavaScript String Literal

JSON-encode AND HTML-encode. <script>

CSS Property Value

CSS-escape: backslash + 6-hex code point. \3C script\3E

A Safe-Output Workflow for User-Submitted Content

01

Identify the Context

HTML body? Attribute? URL? Each has its own encoder.

02

Encode Server-Side First

Never trust client-side sanitization alone. Encode at render time on the server.

03

Apply CSP as Defence-in-Depth

Even if encoding fails, a strict CSP blocks inline scripts and untrusted origins.

04

Audit With This Tool

Decode any HTML you receive from third parties to see what is actually in the payload.

Free HTML Entity Encoder & Decoder Online: XSS-Safe, Unicode-Aware | Toolk