HTML Entity Encoder and Decoder
Escape the characters that HTML reads as markup, or turn named and numeric entities back into text.
How to use
- Choose an Encoding mode. Markup only escapes the five characters that HTML reads as syntax. Named also gives standard names to accented letters and symbols. Numeric writes every non-ASCII character as a decimal number.
- Type or paste text into Input. The page starts with a sample that contains an ampersand, quotation marks and a less-than sign.
- Press Encode to turn characters into entities, or Decode to turn entities back into characters. The mode only affects encoding.
- Read the Output box and the status line. Press Copy output to copy it.
Worked example
The default input is Tom & Jerry say "hi" <3 café. Encoding it gives:
| Mode | Output |
|---|---|
| Markup only | Tom & Jerry say "hi" <3 café |
| Named | Tom & Jerry say "hi" <3 café |
| Numeric | Tom & Jerry say "hi" <3 café |
In every mode the ampersand, the quotation marks and the less-than sign are escaped. Only the é changes between modes. Euro and coffee-cup symbols behave differently: in Named mode €5 ☕ becomes €5 ☕, because the euro sign has a standard name and the coffee cup does not, so it falls back to a number.
Decoding is a single pass. &lt; decodes to < and stops there. It does not continue to <.
How it works
HTML treats &, < and > as syntax, and quotation marks end attribute values. Writing them as character references lets them appear as text. The rules are in the WHATWG HTML Standard, character references, and the full list of names is in its named character references table. A numeric reference gives the Unicode code point in decimal (é) or hexadecimal (é). Unicode itself is documented at unicode.org.
This tool knows the HTML 4 Latin-1 names (code points 160 to 255) and a set of common punctuation, arrows and symbols. It does not carry the whole HTML5 table of more than two thousand names. When decoding, a name outside its list, a bare ampersand and a reference with no closing semicolon are left exactly as typed. The tool also refuses numeric references to zero, to surrogate halves (U+D800 to U+DFFF) and to values above U+10FFFF, because none of them is a character.
Encoding does not make text safe in every position. It is correct for text content and quoted attribute values. It is not enough inside a script, a style block or a URL, which have their own escaping rules. The OWASP Cross Site Scripting Prevention Cheat Sheet explains context-specific output encoding.
Common mistakes and edge cases
- Encoding twice. Encoding text that already contains entities turns
&into&amp;, and the page then shows a literal&. Encode once, at the point of output. - Missing semicolons. Browsers forgive a few legacy references without a semicolon, but this decoder does not.
©stays as typed, while©becomes the copyright sign. - Case matters.
Éandéare different letters. - Unknown names.
&foo;is left alone and is not reported as an error. - Using UTF-8 instead. If a page is served as UTF-8 and declares it, you can write
édirectly. Entities are needed for the five syntax characters, and are optional for the rest. - Non-breaking spaces.
looks like a space but is a different character (U+00A0). It can break string comparisons.
Frequently asked questions
Which mode should I choose?
Markup only is right for most modern pages. Named or numeric are useful when the destination cannot be trusted to read UTF-8, such as some email templates.
Does decoding run the HTML I paste?
No. The page treats your input as plain text and never renders it. Decoded output shows as text in a box.
Why is the apostrophe written as a name?
The five markup characters use the names amp, lt, gt, quot and apos. The name ' is valid in HTML5 but was not part of HTML 4. Use the numeric form ' if your target is very old.
Can I decode hexadecimal references?
Yes. é and é both give é.
Is my text stored?
No. Everything runs in your browser.
Related tools
- Base64 & URL Encoder/Decoder for percent-encoding and Base64.
- Regex Tester to find entities in a block of text.
- Case Converter for changing letter case.
- Meta Tag Generator, which escapes text for attribute values.