HTML Entity Encoder & Decoder
Escape special characters as HTML entities, or unescape entities such as & and é back to readable text. Choose named, decimal or hex entities, and decode every HTML5 entity.
Free HTML Entity Encoder and Decoder
An HTML entity is a piece of text that starts with an ampersand and ends with a semicolon, such as < or ©. Browsers display it as a single character. Entities are how you show characters that HTML reserves for its own use, like the less-than sign, and how you write symbols that are hard to type. This tool encodes text into entities and decodes entities back to normal text. It runs entirely in your browser, so nothing you enter is uploaded.
How to Use the HTML Entity Tool
- Click Encode to turn characters into entities, or Decode to turn entities back into characters.
- When encoding, choose how far to go: special characters only, or non-ASCII characters too, as named, decimal or hex entities.
- Type or paste your text. The result appears as you type.
- Press Copy Output to copy it, or Swap Input and Output to reverse the direction.
Encoding Options Explained
| Option | What it does | Example |
|---|---|---|
| Special characters only | Escapes the five characters that can break HTML: & < > " '. Everything else stays as it is. | Tom & Jerry |
| Named | Also converts non-ASCII characters. It uses the readable name when one exists and a number when it does not. | café €5 |
| Decimal | Converts non-ASCII characters to decimal numbers. | café €5 |
| Hex | Converts non-ASCII characters to hexadecimal numbers. | café €5 |
| Keep existing entities | Leaves things that are already entities alone, so & does not become &amp;. | & stays & |
Example
<p class="intro">Tom & Jerry's café costs 5 €</p>
<p class="intro">Tom & Jerry's café costs 5 €</p>
Common HTML Entities
| Character | Entity name | Numeric |
|---|---|---|
| & | & | & |
| < | < | < |
| > | > | > |
| “ | " | " |
| ‘ | ' | ' |
| non-breaking space | |   |
| © | © | © |
| ® | ® | ® |
| â„¢ | ™ | ™ |
| € | € | € |
| — | — | — |
| … | … | … |
| → | → | → |
Why Encode HTML Entities?
- Show code on a web page. To display
<div>as text instead of having the browser treat it as a tag, the angle brackets must be escaped. - Prevent broken pages. An unescaped ampersand or quote in an attribute value can end the attribute early and break the layout.
- Reduce cross-site scripting (XSS) risk. Escaping user-supplied text before it is placed in HTML stops it from being run as markup or script.
- Handle special symbols. Copyright signs, arrows, currency symbols and non-breaking spaces have entities that work in any file encoding.
A Note on Security
Escaping the five special characters is the core of safe output in an HTML page. In real applications, use the automatic escaping of your template engine or framework, because the correct escaping depends on where the text is placed. Text inside a script, a style block, a URL or an attribute needs different handling from text in the page body. Use this tool for manual tasks such as preparing snippets, checking output and decoding text you have received.
Common Mistakes
- Double escaping. Encoding text that is already encoded turns
&into&amp;, which then shows up as a visible & on the page. Use the keep-entities option, or decode first. - Missing semicolon. Entities should end with a semicolon. Some browsers forgive a few old ones, but not reliably.
- Treating entities as encryption. Writing an email address as entities only hides it from the simplest scrapers. It is not protection.
Privacy
Encoding is done with plain JavaScript in your page. Decoding uses your browser’s own HTML parser in a way that never runs scripts or loads images. Nothing is uploaded, stored or logged.
Frequently Asked Questions (FAQ)
Is the HTML entity encoder and decoder free?
Yes. It is free, needs no sign-up and has no usage limit.
Does the decoder support all HTML entities?
Yes. Decoding uses your browser’s HTML parser, so it understands all named HTML5 entities as well as decimal and hex numeric entities.
What is the difference between named and numeric entities?
A named entity such as © is easier to read. A numeric entity such as © works for every character, including ones that have no name.
Should I use ' for an apostrophe?
It is valid in HTML5 but not in older HTML 4 and some XML-based tools. The numeric form ' works everywhere, so this tool uses it.
Does it handle emoji and other languages?
Yes. Characters outside the basic range, including emoji, are converted to a single numeric entity and decoded back correctly.
Is it safe to paste untrusted HTML into the decoder?
Yes. The decoder only turns entities into text. It does not create page elements, run scripts or load images from what you paste.
Does encoding stop XSS attacks?
Escaping output is a key defence, but it must be done for the right context. Use your framework’s built-in escaping in real applications.
