ToolsForWeb

HTML Entity Encoder / Decoder

Encode text for safe embedding in HTML: basic mode escapes the five XML-critical characters (& < > " '), aggressive mode additionally turns every non-ASCII character into a numeric entity. Decoding handles decimal and hex numeric entities plus about 40 common named ones (&amp;, &nbsp;, &mdash;, accented letters…), tolerates missing semicolons the way browsers do, and leaves unknown entities as literal text. Runs entirely in your browser.

Loading tool…

About this tool

Escapes text for safe inclusion in HTML, or decodes entities back to characters. Basic mode escapes exactly the five characters that break HTML parsing: & < > " and '. Aggressive mode additionally converts every non-ASCII character (é, ☺, emoji) into a numeric entity like &#233;, which is how you make arbitrary text survive any legacy charset or lossy pipeline. Decoding handles decimal and hex numeric entities plus around 40 common named ones — &amp;, &nbsp;, &mdash;, &copy;, accented letters — and tolerates a missing semicolon the way browsers do.

When to use it

Embedding code snippets or user content in HTML without breaking the markup.
Making accented text or emoji survive a system that mangles UTF-8 (aggressive mode).
Cleaning up double-encoded text like &amp;amp; back to a single ampersand.
Checking what an entity string you found in the wild actually renders as.

Questions

Basic or aggressive encoding?

Basic for normal HTML work — those five characters are the only ones that change how a page parses. Aggressive when text must pass through something that is not UTF-8-safe: every non-ASCII character becomes pure ASCII, at the cost of readability in the source.

Why did &ampx stay unchanged?

It is not a known entity. Decoders match whole names, not prefixes — &ampx is the unknown name "ampx", not amp followed by x — so it is left as literal text, exactly like a browser would render it. That behavior also makes typos visible instead of silently corrupting your text.

Are all HTML entities supported?

The named table covers the roughly 40 you actually meet in text: punctuation, symbols and common accented letters. Anything beyond that has a numeric form — every Unicode codepoint can be written as &#NNNN; — and numeric decoding always works, so nothing is undecodable.

Related tools