Encode text to HTML entities or decode them back. Named, decimal and hex output, four encoding levels, XSS warnings. Free and runs in your browser.
By Inventive HQ
This HTML entity encoder converts text into HTML entities and converts entities back into plain text, in one place, instantly. Paste a snippet containing <, >, & or quotes and get output that a browser will display as literal characters instead of parsing as markup. Choose named entities, decimal numeric references, hexadecimal references or a mixed strategy, and choose how aggressive the encoding should be. Everything runs in your browser — nothing is uploaded.
The two jobs it does are exact inverses. Encoding takes <div>Hello</div> and yields <div>Hello</div>, which renders on the page as the tag text rather than creating an element. Decoding takes entity-laden text out of a log line, an XML export or a database column and gives you back the original characters.
HTML has exactly five characters that carry structural meaning. If untrusted input containing them is written into a page unescaped, the browser cannot tell your markup from the attacker's — that is cross-site scripting in one sentence. Entity encoding removes the ambiguity by replacing each dangerous character with a token that means “display this glyph” rather than “begin a tag”.
The five that always need encoding in an HTML context:
& → & (decimal &, hex &) — encode this one first, or you will double-encode everything that follows< → < (<, <)> → > (>, >)" → " (", ") — essential inside double-quoted attributes' → ' (', ') — essential inside single-quoted attributesBeyond those, a useful reference set of named entities: for a non-breaking space, © ©, ® ®, ™ ™, € €, £ £, ¥ ¥, ¢ ¢, ° °, ± ±, × ×, ÷ ÷, ½ ½, ¼ ¼, ¾ ¾, — —, – –, … …, • •, § §, ¶ ¶, † †, ′ ′, ← ←, → →, ↑ ↑, ↓ ↓.
Every character can be written three ways, and the tool lets you pick which:
&, ©. Readable, but only defined for characters that have a name.&. A numeric character reference using the code point in base 10. Works for every Unicode character.&. The same thing in base 16, which is how code points are conventionally written.All three forms are equivalent to the parser. Numeric references are the safer default when output is consumed by something other than a full HTML parser, because named entities beyond the core five are not universally recognised in XML.
Encoding more than necessary bloats output and makes diffs unreadable; encoding less than necessary is a vulnerability. The tool offers four levels so you can match the context:
Entity encoding is contextual output encoding, and the context decides whether it works. Inside an HTML element or a quoted attribute value, it is correct and sufficient. Elsewhere it is not:
<script> — the HTML parser does not decode entities in a script data block, so entity encoding neither protects you nor round-trips. Serialise to JSON instead.javascript: decodes to javascript:, so an entity-encoded payload in href still executes. Validate the scheme, and use percent-encoding via the URL encoder for the query string.The tool flags patterns in your input that suggest an XSS attempt — on* event handler attributes, script and other dangerous tags such as iframe, object, embed and frame, and text that is already heavily entity-encoded (a classic evasion signal). Treat these as review prompts, not as a verdict. And encode on output, never on input: storing pre-encoded data guarantees double-encoding somewhere downstream, which is how &amp; ends up in your page titles. Pair this with a strong Content Security Policy so that a missed escape does not become an executed script.
Decoding accepts all three forms in the same input, so mixed text such as <p>café & bar</p> comes back intact.
It is the replacement of characters that have structural meaning in HTML — or that are hard to type — with escape sequences the browser renders as the literal glyph. < becomes <, so the browser displays a less-than sign instead of starting a tag.
Yes. Free, no account, no length limit, and it runs entirely in your browser.
At minimum &, <, >, " and '. Encode the ampersand first so you do not re-encode the entities you have just created.
Named entities like © are readable but exist only for a defined list of characters. Numeric references — decimal © or hex © — work for any Unicode code point. Browsers treat all three identically.
In HTML element and quoted-attribute contexts, yes. It does not protect JavaScript contexts, URL attributes such as href and src, CSS, or unquoted attributes — each needs its own escaping rules.
No. Store the raw value and encode at the point of output, using the encoding appropriate to that context. Encoding on input causes double-encoding and breaks searching, sorting and reuse in non-HTML contexts.
That is double encoding: an already-encoded string was encoded again. Decode it here until it stops changing, then fix the pipeline so encoding happens exactly once, at output.
Not on a UTF-8 page — they display correctly as-is, so minimal encoding is the right choice. Use extended or standard level only when output passes through a system that cannot handle non-ASCII bytes.
Yes. The decoder handles named entities, decimal references and hexadecimal references in the same input, in any combination.
No. Encoding, decoding and the security checks all run locally in your browser. Nothing is transmitted or stored.