HTML Entities encode/decode
Encode or decode text with htmlentities. No key needed, fully reversible, and nothing leaves your browser.
Which characters become entities
Characters with a meaning in HTML (& < > " ') always become entities. So do all characters that HTML 4.01 has a name for, such as ü, é, © or €. Everything else, including emoji, stays as it is.
<3cbb62>>3eTT54oo6fmm6d␣␣20&&26␣␣20JJ4aee65rr72rr72yy79<<3c//2fbb62>>3e18 bytes in, 34 characters out: +89 %
Typing in the tool above fills this in. Nothing leaves your browser.
What is HTML entities?
HTML entities replace characters that have a meaning in HTML, or that a page can't show, with a reference such as < for < or ü for ü. Encoding them stops user input from breaking a page or injecting markup. This tool works like PHP's htmlentities() with the 252 named entities of HTML 4.01.
- Showing user input on a web page
- Code examples in HTML
- Old pages in ISO-8859-1
- RSS feeds and HTML e-mail
- Template and CMS output
Why won't my HTML entities decode?
Paste what you have. The check tells you what is wrong, what kind of data is inside and shows the decoded result.
- Paste text above or try an example.
htmlentities, htmlspecialchars and numeric
The same input in the forms you meet in practice. Shown for <b>Tom & Jerry</b>; type in the box above or in the tool to use your text.
- htmlentitieswhat the tool returns
<b>Tom & Jerry</b>- htmlspecialcharsonly & < > " ' – enough with UTF-8
<b>Tom & Jerry</b>- Numeric, decimalworks in HTML and XML
<b>Tom & Jerry</b>- Numeric, hexworks in HTML and XML
<b>Tom & Jerry</b>
The same result in your code
Every snippet encodes <b>Tom & Jerry</b> to <b>Tom & Jerry</b> exactly like the tool, then decodes it back. They are run and compared with the tool before each release.
echo htmlentities('<b>Tom & Jerry</b>'), "\n"; echo html_entity_decode('<b>Tom & Jerry</b>'), "\n";
Python, JavaScript, Java and Go have no built-in function with PHP's full entity table. Python's html.escape() and Go's html.EscapeString() only replace & < > " ', like htmlspecialchars(), which is all a UTF-8 page needs. For decoding, Python's html.unescape() knows every HTML5 entity.
HTML entities examples and test values
What the tool returns for these inputs (UTF-8). Use them to check your own code. ↵ marks a line break.
| Input | HTML entities |
|---|---|
<b>Tom & Jerry</b> | <b>Tom & Jerry</b> |
"double" and 'single' | "double" and 'single' |
Grüße aus München | Grüße aus München |
© 2026 · €5 → 10 | © 2026 · €5 → 10 |
naïve café | naïve café |
🙂 | 🙂 |
Why your HTML entities doesn't match
If a page shows & or <b>, the text was encoded twice. Template engines (Twig, Blade, Jinja, React) escape on their own; encode only once, at output.
With UTF-8 pages only & < > " ' have to be replaced. htmlentities() also turns ü into ü, which makes text longer and harder to search. htmlspecialchars() is usually the better choice; compare both below.
Entities protect HTML text and quoted attributes. They don't protect values inside <script>, onclick or href="javascript:…". Use JSON encoding for JavaScript and URL encoding for links.
' comes from XML and HTML5. PHP's HTML 4.01 mode writes ' as ' and leaves ' undecoded.
ä without ; is not decoded by PHP. Browsers guess some names without semicolon, which is why text can look fine in the browser and wrong in your data.
Like the form on the original site, the tool removes spaces and line breaks at the start and end, and sends line breaks as CRLF (\r\n). That is why a result can differ from your code by one line break.
Questions about HTML entities
What is the difference between htmlentities and htmlspecialchars?
htmlspecialchars only replaces & < > " and ', which is all a UTF-8 page needs. htmlentities also replaces every character that has a named entity, such as ü with ü and € with €.
Does htmlentities prevent XSS?
In HTML text and in quoted attribute values, yes. It does not protect values inside <script>, event handlers like onclick or javascript: URLs. Those need JSON or URL encoding and a content security policy.
Why does my page show &amp;?
The text was encoded twice: the & of & was encoded again. Usually a template engine escapes on its own and the code encodes as well. Encode once, at output.
Which entities does this tool know?
The 252 named entities of HTML 4.01, plus numeric ones like ü and ü, exactly like PHP's htmlentities() and html_entity_decode() in HTML 4.01 mode.