— Developer Tools

Free HTML Entity Encoder and Decoder

Escape the five characters that break HTML, or decode &-style references from any page back into plain text.

— Samples
In 38Out 64Valid
Live

What is a HTML Entity Encoder and Decoder?

An HTML entity encoder rewrites characters that have a special meaning in HTML, such as the less-than sign and the ampersand, as character references like < and &. A decoder turns references back into the characters they stand for.

This tool uses the full table of 2,231 named character references from the WHATWG HTML Standard, through the open-source entities library. It offers three ways to encode: escape only the five special characters, encode with named references where they exist, or encode with numeric hex references that are also valid in XML. Decoding follows the same rules browsers use, including the old forms written without a semicolon.

Key Features

Minimal Escaping by Default

Escape only rewrites the ampersand, less-than, greater-than and both quote marks, and leaves accents and emoji as UTF-8. That is the safe choice for text going into HTML or an attribute.

Every HTML5 Name Decoded

All 2,231 named references decode, from & to ’, not just the dozen most common. Hex and decimal numeric references decode too.

Decodes Like a Browser

A bare ampersand stays as typed, and legacy names such as &copy without a semicolon still decode. The result matches what a browser would show for the same source.

XML-Safe Numeric Mode

Numeric mode writes references such as © that every HTML and XML parser accepts. Use it for RSS feeds, SVG and email templates.

Your Markup Stays Local

Encoding and decoding run in your browser, so draft content, templates and scraped pages aren’t sent to a server.

Emoji and Rare Symbols Covered

Characters above U+FFFF, including emoji, encode as a single numeric reference such as 😀. They decode back to the same character, not two broken halves.

Perfect for everyone

  • Front-end developers escaping user content
  • Content editors fixing CMS output
  • Email developers building HTML templates
  • Scrapers cleaning extracted text

How to Use the HTML Entity Encoder and Decoder

Choose how to encode or decode, paste, and copy the result.

1

Pick a Mode

Choose Escape only for text going into HTML, Named for readable references like é, Numeric for XML-safe output, or Decode to turn references back into characters.

2

Paste the Text or Markup

Paste a snippet, a paragraph or a whole template. Inputs up to 200,000 characters convert instantly, and line breaks are kept.

3

Check the Converted Text

The result updates with every keystroke. When decoding, look out for references that stayed as typed, since an unknown or misspelled name isn’t a character.

4

Paste It Back Where It Belongs

Copy escaped text into your template, attribute or email, or copy decoded text into a document or spreadsheet. The In and Out counts show how much escaping added.

Worked Examples

Real Input and Output

These rows were converted by this tool, and each answer is its exact output. Guess the result first, then reveal it.

REF_001Escape only

“<a href="/search?q=1&lang=en">Café</a>”

REF_002Escape only, math

“5 > 3 & 2 < 4”

REF_003Named

“Café crème — 5 €”

REF_004Named, curly apostrophe

“It’s 9 > 8”

REF_005Numeric

“<p>© 2026 Tom & Jerry’s</p>”

REF_006Numeric, emoji

“Thanks 😀”

REF_007Decode, mixed

“Fish &amp; Chips &mdash; &pound;9 &#x1F41F;”

REF_008Decode, escaped tag

“&lt;script&gt;alert(1)&lt;/script&gt;”

REF_009Decode, no semicolon

“AT&T &copy 2026”

REF_010Decode, legacy prefix

“&notanentity; &amp;amp;”

Reference Table

Character References Worth Knowing

A handful of references cover most real HTML. These entries explain each one and the parsing rules around them.

01 / AMPERSAND

Ampersand Is &amp;

The ampersand starts every reference, so a literal one in text or a URL attribute is written &amp;. It is the first character to escape and the most often forgotten.

“How is a literal ampersand written?”

02 / LESSTHAN

Less-Than Is &lt;

The less-than sign opens a tag, so text that contains one must escape it or the browser starts parsing markup. This is the core of preventing script injection.

“How is the less-than sign written?”

03 / GREATERTHAN

Greater-Than Is &gt;

The greater-than sign closes a tag. Escaping it isn’t strictly required in text, but escaping both brackets keeps output readable and consistent.

“How is the greater-than sign written?”

04 / QUOTES

Quotes Inside Attributes

A double quote inside a double-quoted attribute value ends it early, so it becomes &quot;. A single quote becomes &apos; or &#x27; inside single-quoted values.

“How is a double quote written in an attribute?”

05 / NONBREAKING

Non-Breaking Space Is &nbsp;

&nbsp; is U+00A0, a space that never wraps to a new line. It is the most common reference in copied web text and often hides in data.

“Which code point is &nbsp;?”

06 / HEX

Hex and Decimal Numeric References

&#xE9; and &#233; both mean é: the first is hexadecimal, the second decimal. Any code point can be written this way, emoji included.

“What is &#169;?”

07 / NAMED

Named References Are Case-Sensitive

&Eacute; is É and &eacute; is é, and &AMP; is a separate legacy name. Spell names exactly, or they stay as plain text.

“Is &Eacute; the same as &eacute;?”

08 / SOME

Some Names Work Without a Semicolon

For compatibility, browsers still decode about a hundred old names such as &copy and &amp without their semicolon. Always write the semicolon; never rely on this.

“Does &copy 2026 show ©?”

09 / XML

XML Has Only Five Built-In Names

XML predefines just &amp;, &lt;, &gt;, &quot; and &apos;. Names like &eacute; break an XML or RSS parser, so use numeric references there.

“Is &nbsp; valid in plain XML?”

10 / UNKNOWN

Unknown Names Stay as Text

A misspelled or invented name isn’t an error in HTML; it is shown literally. That is why &copyright; displays as ©right; and not as a symbol.

“What does &copyright; show?”

Which Encoding Mode to Use

The right mode depends on where the text is going, not on the text itself.

Escape Only for HTML Text and Attributes

Rewriting just the five special characters is enough to make text safe inside HTML elements and quoted attributes. Accents and emoji stay readable in the source.

Named for Readable Source

Named references like &eacute; and &mdash; show what the character is when you read the source. They also encode punctuation such as = and /, so the output is long.

Numeric for XML, RSS and SVG

XML parsers only know five names, so feeds and SVG files need numeric references for anything else. Numeric mode writes those for every non-ASCII character.

Numeric for ASCII-Only Channels

Some legacy email systems and databases can’t store UTF-8. Numeric references keep every character as plain ASCII until the HTML is rendered.

Decode for Scraped and Exported Text

Text taken from HTML, RSS or a CMS export often still carries &amp; and &#39;. Decoding turns it into clean text for documents and spreadsheets.

Not for JavaScript or URLs

Entities only work in HTML and XML. Inside a script string use JavaScript escapes, and inside a link use percent-encoding instead.

Escape Only for JSON Inside HTML

Text placed in a data attribute and later read by JavaScript needs its quotes and brackets escaped. Escape only covers exactly those characters without bloating the rest.

Decode Before Counting Characters

A meta description stored with &amp; and &quot; looks longer than it renders. Decode it first to measure the length a search engine will actually show.

Escaping Mistakes That Cause Bugs

Most entity bugs are either double escaping or escaping in the wrong place.

Tip 01

Double Escaping

Escaping already escaped text turns &amp; into &amp;amp;, which shows up on the page as a literal &amp;. Escape once, at output, and store raw text.

Tip 02

Escaping Isn’t Sanitising HTML

Escaping makes text display as text. If you need to allow some tags, such as bold and links, use an HTML sanitiser instead of selectively unescaping.

Tip 03

Unquoted Attributes

Escaping protects quoted attribute values, but an unquoted value can be broken by a space. Always quote attributes in templates.

Tip 04

Named References in XML

&nbsp; or &eacute; in an RSS feed makes the whole feed fail to parse. Switch to numeric mode for anything that isn’t HTML.

Tip 05

Forgetting the Ampersand in URLs

Query strings in href attributes contain &, which should be &amp; in the HTML source. Validators flag it, and some names after & can be misread as references.

Tip 06

Decoding Untrusted HTML Into a Page

Decoding &lt;script&gt; produces a working script tag. Never insert decoded text back into a page as HTML; insert it as text.

Tip 07

Spot Double Escaping by Its Pattern

Seeing &amp;amp; or &amp;lt; in a page is the signature of escaping twice. Decode once here; if the result still contains references, find the second escape in your pipeline.

Tip 08

Non-Breaking Spaces Hiding in Data

Decoded &nbsp; becomes U+00A0, which looks like a space but isn’t one to code. Trim and split functions miss it, so replace it with a normal space after decoding.

Everyday Entity Jobs

Entities appear wherever text and HTML meet.

Showing Code on a Web Page

Escape a snippet of HTML before putting it in a blog post or docs page, so readers see the tags instead of the browser rendering them.

Cleaning Scraped Text

Text extracted from web pages often contains &nbsp; and &#8217;. Decode it before analysis so word counts and searches work on real characters.

Fixing CMS Output

When a CMS shows &amp;amp; or &quot; on the live site, decode the stored value here to see how many times it was escaped.

Building HTML Email Templates

Encode symbols such as ©, ™ and curly quotes as numeric references so they survive email clients with poor UTF-8 handling.

Writing RSS and Sitemap Files

Titles with ampersands or accents must be XML-safe. Numeric mode gives output any feed reader accepts.

Reviewing Escaped Payloads

Security reviews often meet escaped markup in logs or bug reports. Decode it to read what was submitted, without letting it run.

Preparing Attribute Values

Escape a product name with quotes or an ampersand before putting it in an alt or title attribute in a hand-written template.

Comparing Text Across Systems

A product name exported from a CMS may read Tom &amp; Jerry while the database says Tom & Jerry. Decode both to compare the real values before deduplicating.

Frequently Asked Questions