Công Cụ Nhanh

HTML entity encoder and decoder

Mode

Characters without an HTML name fall back to a number.

56 characters → 82 characters

Entity encoding is not a complete XSS defence

Escaping & < > " ' is safe for HTML element content and quoted attributes. It is NOT enough inside <script>, event attributes (onclick), href="javascript:…" URLs, CSS or unquoted attributes. Use your framework's built-in escaping (React, Blade, Twig, PHP htmlspecialchars) and sanitise HTML with a library such as DOMPurify.

Common entities

CharNameDecimalHexMeaning
&&amp;&#38;&#x26;Ampersand (must escape)
<&lt;&#60;&#x3C;Less-than, opens a tag
>&gt;&#62;&#x3E;Greater-than
"&quot;&#34;&#x22;Double quote in attributes
'&apos;&#39;&#x27;Apostrophe (HTML5)
␣&nbsp;&#160;&#xA0;Non-breaking space
©&copy;&#169;&#xA9;Copyright
®&reg;&#174;&#xAE;Registered
™&trade;&#8482;&#x2122;Trademark
€&euro;&#8364;&#x20AC;Euro
°&deg;&#176;&#xB0;Degree
×&times;&#215;&#xD7;Multiplication
÷&divide;&#247;&#xF7;Division
±&plusmn;&#177;&#xB1;Plus-minus
–&ndash;&#8211;&#x2013;En dash (1–5)
—&mdash;&#8212;&#x2014;Em dash
…&hellip;&#8230;&#x2026;Ellipsis
«&laquo;&#171;&#xAB;Left angle quote
»&raquo;&#187;&#xBB;Right angle quote
“&ldquo;&#8220;&#x201C;Left curly quote
”&rdquo;&#8221;&#x201D;Right curly quote
•&bull;&#8226;&#x2022;Bullet
·&middot;&#183;&#xB7;Middle dot
→&rarr;&#8594;&#x2192;Right arrow
←&larr;&#8592;&#x2190;Left arrow
♥&hearts;&#9829;&#x2665;Heart
✓&check;&#10003;&#x2713;Check mark
đ&dstrok;&#273;&#x111;Vietnamese đ
ă&abreve;&#259;&#x103;Vietnamese ă
ê&ecirc;&#234;&#xEA;e with circumflex

Processed in your browser. Your files and data are never uploaded to a server.

Quick answer

An HTML entity writes a character as a code that starts with & and ends with a semicolon: &lt; is <, &amp; is &, and &#233; or &#xE9; is é. At minimum, escape the five characters & < > " ' whenever you want them shown as text instead of being read as HTML.

What is an HTML entity?

Paste text or HTML to turn special characters into entities, or paste a string full of &amp;, &nbsp; or &#8217; to decode it back to plain text. You can escape only the five special characters (enough in most cases) or every non-ASCII character such as accented letters and emoji, as named (&eacute;), decimal (&#233;) or hex (&#xE9;) entities. Decoding also understands old Windows-1252 style codes (&#150;) the way browsers do. Everything runs on your device.

Illustration of an angle-bracket card being wrapped into a paper parcel tied with string, next to an unwrapped card, scissors and a roll of tape

How to encode or decode HTML entities

  1. 1

    Choose “Encode” or “Decode” at the top of the tool.

  2. 2

    When encoding, pick the scope: special characters only (accented letters stay as they are) or every non-ASCII character (for ASCII-only systems and old email), then choose the entity format.

  3. 3

    Paste your content on the left; the result appears on the right straight away. Press “Copy” to take it.

  4. 4

    Press “Swap” to move the output into the input and run the opposite direction, a quick way to check that encoding then decoding gives back the original.

The 5 characters you must escape in HTML

CharacterNamedNumericWhy
&&amp;&#38;Starts every entity; left alone it can be misread (for example &copy in a URL)
<&lt;&#60;Opens an HTML tag and can make the browser run unexpected code
>&gt;&#62;Closes a tag; escape it for consistency and safety
"&quot;&#34;Ends an attribute value wrapped in double quotes
'&apos;&#39;Ends a single-quoted attribute; &apos; is missing from HTML4, so &#39; is common

Swipe sideways to see the whole table →

Three ways to write the same character

FormExample for ©Notes
Named&copy;Readable, but only about 2,000+ characters have names in the HTML standard
Decimal&#169;Works for any Unicode character
Hex&#xA9;Same value, written as the Unicode code point U+00A9

Real-world examples

Showing code in a blog post

To display <div class="box"> instead of creating a real div, encode it as &lt;div class=&quot;box&quot;&gt; and paste that into the HTML editor.

Product names showing “&amp;amp;”

The data was escaped twice on its way through several systems. Decode once to get “&amp;”, again to get “&”, then remove the extra escaping step.

Garbled characters in email

An old mailer without a UTF-8 header turns “café” into “café”. Encoding non-ASCII characters as &#233; makes the text display correctly in any encoding.

Scraped text full of &nbsp;

Text copied from web pages often contains &nbsp; and &#8211;. Decode it to get real spaces and dashes before pasting into a spreadsheet.

Common mistakes

Double escaping into &amp;lt;.
Escape in ONE place, right when inserting into HTML. If your framework (React, Blade, Twig) already escapes output, do not escape again.
Assuming entity encoding stops XSS everywhere.
Entities are only safe for element content and quoted attributes. Inside <script>, onclick, href="javascript:" or CSS you need different escaping, or better, no user data at all.
Missing semicolons: &copy 2026.
Browsers guess some legacy names but not reliably; always write &copy; in full. This tool also only decodes entities that end with a semicolon.
Encoding every accented letter bloats the HTML.
If the page declares <meta charset="utf-8">, there is no need: choose “Special characters only”.

Do I need to encode accented or non-English letters?

No, if the page uses UTF-8 (almost every website today). Accented letters written directly in HTML display correctly, keep files smaller and are easier to edit.

Encode every non-ASCII character only when content passes through systems with an uncertain encoding: old HTML email, XML files sent to other software, or strings that must sit in ASCII-only source code.

Glossary

Entity
A &…; sequence standing for one character, such as &amp; for &.
Named reference
An entity with a name like &nbsp; or &copy;, predefined by the HTML standard.
Numeric reference
An entity written as a number: &#233; (decimal) or &#xE9; (hex) for the Unicode code point.
Escaping
Replacing characters that have a special meaning with a safe form so they display as plain text.
XSS
Cross-site scripting: injecting script into a page through user input that was not escaped properly.
&nbsp;
A non-breaking space that keeps two words on the same line, as in “100&nbsp;km”.

Frequently asked questions

How is &nbsp; different from a normal space?

Browsers never break a line at &nbsp; and do not collapse several of them into one like normal spaces. Do not use it for layout; use CSS.

Should I use &apos; or &#39;?

Both are the apostrophe. &apos; exists in HTML5 and XML but not in HTML4, so &#39; is safer for email and old browsers; this tool uses &#39;.

Do named and numeric entities display differently?

No. &copy;, &#169; and &#xA9; all render as ©. Names are easier to read; numbers work for every character, including emoji.

Which PHP function escapes HTML?

htmlspecialchars($s, ENT_QUOTES, 'UTF-8') escapes the five special characters, like the “Special characters only” mode; htmlentities also escapes every character that has a name. Use html_entity_decode to decode.

Does JavaScript have a built-in HTML escape function?

There is no standard one. Assigning the string to an element's textContent (instead of innerHTML) is the safest approach, and React and Vue escape variables automatically.

Why is an entity left undecoded?

The tool knows the commonly used names (Latin-1, Latin letters with names, maths symbols, arrows, Greek). Rare names are kept as they are and listed in the status line; numeric entities are always decoded.

Ratings and comments

Loading…