Guide
HTML entities - when to escape text and how
Some characters have a special meaning in HTML. A < starts a tag, a & starts an entity, and a " can end an attribute. To show those characters as text, for example in a code sample, a blog post about HTML, or a product name like “R&D Tools”, they must be written as entities: <, &, ". This tool converts text to entities and back.
Encoding text
- Choose Encode and paste your text.
- Pick which characters:
- Only & < > “ ’: the minimum for correct HTML. Use this almost always.
- Also all non-ASCII: additionally converts accented letters, symbols and emoji, for legacy systems and fragile email templates.
- Pick the entity style: named (
&,©) or numeric (&,©). - Copy the result into your HTML.
| Character | Named | Numeric |
|---|---|---|
| & | & |
& |
| < | < |
< |
| > | > |
> |
| “ | " |
" |
| ’ | ' |
' |
| © | © |
© |
| non-breaking space | |
  |
Characters that have no named entity, such as most emoji, are always written numerically.
Decoding text
Choose Decode and paste text full of entities, such as Tom & Jerry’s "Best". You get plain text back: Tom & Jerry’s “Best”. Decoding uses the browser’s own HTML parser, so every named and numeric entity is understood. Typical sources are RSS feeds, scraped pages, CMS exports and database fields that were escaped twice.
When you need it
- Code samples in blog posts, documentation and tutorials: escape
<div>so it appears as text. - User-visible text with ampersands or angle brackets in hand-written HTML or templates.
- Attribute values containing quotes, such as
title="The "best" tool". - Legacy and email HTML, where encoding non-ASCII characters avoids broken accents.
- Cleaning data that arrives double-escaped, like
&amp;: decode until it reads correctly.
Escaping and security
Escaping text before inserting it into HTML is a core defense against cross-site scripting (XSS): an escaped <script> is displayed rather than run. But correct escaping depends on context: HTML text, attributes, URLs, JavaScript and CSS each have their own rules. In applications, rely on your framework’s automatic escaping (React, Vue, Django and most template engines do this by default) and use this tool for content, documentation and debugging, not as a sanitizer.
Do you need to encode accents?
On modern pages served as UTF-8 with <meta charset="utf-8">, you can write é, ñ, € and emoji directly. Encoding them only makes the source harder to read. Reach for all non-ASCII when a system mangles UTF-8, or when pasting into a template whose encoding you don’t control.
Who encodes HTML entities
- Bloggers and technical writers show HTML code examples on web pages.
- Developers escape text in templates and debug double-escaped data.
- Email developers encode special characters for older email clients.
- Content editors clean up text full of entities from feeds and exports.
A complete example: a code sample in a blog post
- Paste the HTML you want to show, such as
<button class="primary">Buy</button>. - Encode only the special characters.
- Paste the result inside a
<pre><code>block in your post; readers see the code instead of a button.
Tips
- Most blog editors and Markdown code blocks escape automatically; use this for hand-written HTML.
- Decode text with entities like
&amp;until it reads normally.
Related tools
- URL Encoder for text inside URLs.
- Base64 Encoder for binary data as text.
- Markdown Editor to write formatted text without hand-writing HTML.
- Find and Replace for bulk text cleanup.
Checked against the current version of the HTML Entities on .

