How to use the HTML entities tool
- Choose Encode to escape text or Decode to resolve entities, using the Operation list.
- Paste the text or markup into the Text or encoded value box.
- Select Convert. The Example button runs the encoder on Hello, world!, which has nothing to escape and comes back unchanged.
- Select Copy to take the converted text from the Result box.
What HTML entities are for
HTML gives a few characters a structural job. The less-than sign opens a tag, the ampersand starts a character reference, and quotes end attribute values. To show those characters as text you write a character reference in their place: a named one such as < or a numeric one such as < or <.
Escaping is also a security measure. If user input reaches a page unescaped, a visitor can inject a script element or an event-handler attribute, which is cross-site scripting. Replacing the special characters before output makes the browser treat the input as inert text.
What the HTML entities encoder escapes
Encode replaces five characters and leaves everything else alone. Letters with accents, symbols such as the copyright sign, CJK text and emoji pass through unchanged, since a UTF-8 page can carry them directly.
The apostrophe is written as ' and not ' because the named form was not part of HTML 4, while the numeric form works in every parser. Text that already contains entities is escaped again, so & turns into &amp;. Encode once, at the point of output.
- The ampersand becomes &
- The less-than sign becomes <
- The greater-than sign becomes >
- The double quote becomes "
- The apostrophe becomes '
<p class="note">Fish & Chips</p>
→ <p class="note">Fish & Chips</p>How decoding works in this tool
Decode hands your text to the browser's own HTML parser and reads back the resulting text. That covers every named reference in the HTML standard (there are more than 2,000) and decimal and hexadecimal numeric references.
Before parsing, each less-than sign in the input is neutralized, so tags are never interpreted. Markup in your input comes back as literal text with its entities resolved, and no script or image in it can run or load.
- Café & crème decodes to Café & crème.
- € and € both decode to the euro sign.
- A few legacy names work without the semicolon, so © 2024 decodes to © 2024.
- Unknown names such as &unknown; are left as typed.
- Decoding happens once, so &lt; becomes < and stays an entity.
Common mistakes with escaping
Entity escaping is correct for HTML text content and quoted attribute values. Other contexts differ: a value inside a script block needs JavaScript string escaping, a value in a URL needs percent-encoding, and CSS has its own rules.
Double encoding is the other frequent bug. When a page shows &amp; or < as visible text, the data was escaped twice, often once when stored and again when rendered. Decode it once here to see what the stored value really is.
Frequently asked questions
What is the difference between ' and '?
Both stand for the apostrophe. ' comes from XML and entered HTML only with HTML5, while the numeric ' is understood everywhere. The encoder outputs ', and the decoder accepts either form.
Does the encoder convert accented letters or emoji to entities?
No. Only the ampersand, less-than sign, greater-than sign, double quote and apostrophe are replaced. Other characters stay as they are, which is safe as long as the page is served as UTF-8.
Is it safe to decode untrusted HTML here?
Yes. The tool escapes every less-than sign before parsing and reads only the text of the result, so the input is never turned into elements. Scripts and images in the pasted markup are not executed or fetched.
Why does decode to something that looks like a space?
is the no-break space, U+00A0. It looks like an ordinary space but is a different character, which can break string comparisons and trimming.
Should I escape data before saving it to a database?
Usually not. Store the raw text and escape it when you write it into HTML. Escaping at storage time leads to double encoding and corrupts the data for other uses such as JSON APIs, emails and exports.