HTML entity encoder and decoder
Paste text to turn characters such as < > & and quotes into HTML entities that are safe to put in a page, or paste entities to see the characters they stand for. Nothing leaves your browser.
Runs in your browser: nothing you enter is sent anywhere.
How to use it
- Choose Encode or Decode and paste your text.
- When encoding, pick how far to go: only the five markup characters, or also letters like é and symbols like © as entities.
- Copy the result.
How it works
Encoding replaces &, <, >, " and ' first. With the extended options, every other character above U+007F is replaced too: by its name if the table has one (é → é), otherwise by its decimal code (😀 → 😀), or by its hexadecimal code when that box is ticked.
Decoding reads each entity once, so &lt; becomes < and not <. Numeric references outside the valid Unicode range, and names the table does not contain, are kept unchanged.
Example
<a href="x">Tom & Jerry</a> with the basic setting becomes:
<a href="x">Tom & Jerry</a>
Tips
Escape text exactly once. Encoding something that is already encoded turns & into &amp;, which shows up on the page as a literal &.
Frequently asked questions
Which characters must be escaped in HTML?
The ampersand and the less-than sign always, because they start entities and tags. Inside attribute values you also escape the quote you used, and the greater-than sign is escaped by habit. The Basic option covers all five of & < > " and '.
What is the difference between named and numeric entities?
A named entity such as © is easy to read, while a numeric one such as © (decimal) or © (hexadecimal) points to the Unicode code point and works for every character, including emoji. Both decode to the same character.
Does the decoder know every named entity?
No. HTML5 defines about 2,200 names. This tool knows the roughly 250 most common ones (the HTML 4 set of Latin-1 letters, Greek letters, arrows, math symbols and typographic marks, plus ') and every numeric form. A name it does not know, like &foo;, is left as written.
Do I need to encode non-ASCII characters at all?
Not if your page is served as UTF-8, which is the norm. Writing é directly is fine. Encoding non-ASCII is useful for old systems, e-mail templates and files whose encoding you cannot control.
Why is the apostrophe written as ' and not '?
' is part of XML and HTML5 but not HTML 4, and some old parsers ignore it. The numeric form works everywhere.