Vaultools
Menu
network requests sent: 0

HTML Entity Encoder & Decoder

Escape text so it shows up literally in a web page, or turn entities like & and   back into characters. Decoding follows the same rules a browser uses, so you see what would really be rendered, including the mistakes. Everything runs in your browser.

Mode
Characters to encode
Write references as

Find an entity

Search all 2,125 named entities by name (arrow, dash), paste a character (©), or enter a code point (U+2014, —).

Ad · placeholder

Your ad could be here — privacy-respecting, no tracking.

Go Pro to remove this →

What HTML entities are

An HTML entity, properly a character reference, is a way of writing a character that would otherwise be read as markup, or that is hard to type or see. It starts with & and ends with ;, and comes in three forms that all mean the same thing:

Numeric references work for every Unicode character and in XML too. Named ones exist for 2,125 characters in HTML5, but XML, and so SVG and XHTML served as XML, knows only &, <, >, " and '.

Which characters you have to escape

On a page served as UTF-8, which is nearly all of them today, you only need entities for characters HTML itself would misread. Which ones depends on where the text goes:

Where Escape Notes
Text between tags & and < Escaping > as well is conventional and harmless.
Double-quoted attribute & and " title="Say &quot;hi&quot;"
Single-quoted attribute & and ' title='It&#39;s here'
Unquoted attribute Avoid it Spaces, quotes, =, <, > and ` all end or break the value. Quote it instead.
Inside <script> or <style> Nothing works Entities are not decoded there. Use the language’s own escaping, e.g. JSON.

Escaping all five of & < > " ', as this tool's default does, is safe in text and in either kind of quoted attribute. It is not enough on its own for values placed in a URL attribute (href="javascript:…" contains nothing to escape), in inline event handlers, or in CSS. Those need validation or their own encoding, such as percent-encoding for URL parts. Templating engines that escape automatically are the reliable fix for cross-site scripting.

Common HTML entities

Char Named Decimal Hex Description
& &amp; &#38; &#x26; Ampersand. Always escape it in HTML
< &lt; &#60; &#x3C; Less-than sign. Escape it in text so it can’t start a tag
> &gt; &#62; &#x3E; Greater-than sign
" &quot; &#34; &#x22; Double quote. Escape it inside double-quoted attributes
' &apos; &#39; &#x27; Apostrophe. HTML5 only; &#39; also works in old HTML and email
(space) &nbsp; &#160; &#xA0; Non-breaking space: keeps two words on one line
(invisible) &shy; &#173; &#xAD; Soft hyphen: a hyphen shown only if the word breaks there
© &copy; &#169; &#xA9; Copyright sign
® &reg; &#174; &#xAE; Registered trademark sign
™ &trade; &#8482; &#x2122; Trademark sign
— &mdash; &#8212; &#x2014; Em dash
– &ndash; &#8211; &#x2013; En dash, for ranges like 9–5
… &hellip; &#8230; &#x2026; Horizontal ellipsis
‘ &lsquo; &#8216; &#x2018; Left single quotation mark
’ &rsquo; &#8217; &#x2019; Right single quotation mark, also the typographic apostrophe
“ &ldquo; &#8220; &#x201C; Left double quotation mark
” &rdquo; &#8221; &#x201D; Right double quotation mark
« &laquo; &#171; &#xAB; Left guillemet
» &raquo; &#187; &#xBB; Right guillemet
• &bull; &#8226; &#x2022; Bullet
· &middot; &#183; &#xB7; Middle dot
° &deg; &#176; &#xB0; Degree sign
± &plusmn; &#177; &#xB1; Plus-minus sign
× &times; &#215; &#xD7; Multiplication sign
÷ &divide; &#247; &#xF7; Division sign
≠ &ne; &#8800; &#x2260; Not equal to
≤ &le; &#8804; &#x2264; Less than or equal to
≥ &ge; &#8805; &#x2265; Greater than or equal to
½ &frac12; &#189; &#xBD; Vulgar fraction one half
← &larr; &#8592; &#x2190; Left arrow
→ &rarr; &#8594; &#x2192; Right arrow
↑ &uarr; &#8593; &#x2191; Up arrow
↓ &darr; &#8595; &#x2193; Down arrow
✓ &check; &#10003; &#x2713; Check mark (HTML5 only)
€ &euro; &#8364; &#x20AC; Euro sign
£ &pound; &#163; &#xA3; Pound sign
¥ &yen; &#165; &#xA5; Yen sign
¢ &cent; &#162; &#xA2; Cent sign
§ &sect; &#167; &#xA7; Section sign
&para; &#182; &#xB6; Pilcrow (paragraph sign)

Mistakes that show up on real pages

FAQ

What is &nbsp;?

A non-breaking space (U+00A0). It looks like a normal space, but a line never breaks at it, and several in a row aren't collapsed into one. Its numeric forms are &#160; and &#xA0;.

Why does my page show &amp; or &quot;?

The text was escaped twice, so the browser decodes one layer and shows the second. Paste it into the decoder above: it will point out the double encoding. Then find the step that escapes data that was already escaped.

Do I still need entities for accented letters and symbols?

Not on a UTF-8 page. You can type é, —, € or ✓ directly. Entities remain useful for the characters HTML treats specially, for invisible ones like &nbsp; and &shy; that are easy to lose in an editor, and for output that must stay pure ASCII, such as some email templates. Choose "Also everything outside ASCII" above for that.

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

Both mean an apostrophe in HTML5. &apos; wasn't defined in HTML 4, and some older email clients don't recognize it, so &#39; is the safer choice and the one this tool writes.

How do I encode HTML entities in JavaScript?

For text you insert into a page, set element.textContent rather than innerHTML, and the browser treats it as text with no escaping needed. When you must build an HTML string, replace & first, then < > " '. Replacing & last would double-encode the entities you just wrote.

Related glossary terms