How to use the HTML entity tool
- Choose Encode or Decode.
- For encoding, choose what to escape: Only & < > “ ’, Also non-ASCII, or All symbols.
- Choose the style: named (
&), decimal (&) or hex (&). - Paste your text and copy the result.
When decoding, named, decimal and hex references are all recognised. Unknown names stay as they are and are listed under the result.
How character references work
HTML reserves a few characters: < starts a tag, & starts a character reference, and quotes end attribute values. To show them as text, you write a reference instead:
<for<,>for>,&for&,"for"and'for'.- Numeric references name any Unicode code point:
€or€is €.
The HTML standard defines over 2,000 names. This tool includes the common ones (typography, currency, arrows, maths and accented letters used in English, German and Spanish) and uses numeric references for everything else, so the output is always valid. Decoding replaces invalid code points (such as lone surrogates) with the replacement character, as browsers do.
Worked examples
Example 1: showing code in a blog post
You want readers to see <p class="note"> instead of the browser treating it as a tag. Encode with the default option and paste the result inside <pre><code>. The tags appear exactly as typed.
Example 2: an ASCII-only email template
Some email systems mangle non-ASCII text. Encode with Also non-ASCII and the named style: café becomes café and €5 becomes €5, which every email client displays correctly.
Example 3: cleaning scraped text
Text copied from a CMS export contains ’, “ and 😀. Decode it to get curly quotes and the emoji back. The sample also contains &bogus;, which is listed as unknown so you can fix it by hand.
Escaping vs encoding
Entity escaping is for HTML. For other places, use the right tool:
- URLs: percent-encoding (
%20), with the URL encoder. - JavaScript strings:
éescapes or JSON encoding. - CSS content:
\E9escapes.
Mixing them up is a common source of bugs and security holes.
Common mistakes
- Double escaping.
&amp;shows up as&on the page. Escape once, at output time. - Escaping accents unnecessarily on UTF-8 pages, which makes source code hard to edit.
- Forgetting the semicolon.
©works in some places by legacy rules, but©always works. - Escaping for the wrong context. HTML escaping doesn’t make a value safe inside a
<script>block or ajavascript:URL.