DevToolCase
Sign in Sign in

Encode HTML entities

Escape & < > " ' for HTML, or every accent and symbol too, as named (&eacute;) or numeric (&#233;) entities; decode them in one click.

Share this result

Encrypted in your browser. The key stays in the link, after “#”: only the people you give it to can read it, not even DevToolCase.

The link works for

Sign in for longer links or links without expiry, and to find them in your account.

Runs entirely in your browser: nothing you type is sent or stored.

Why escape HTML?

A text inserted into a page as HTML is read as markup: a user name or a comment holding <script> would run in the browser of every visitor. This is cross-site scripting (XSS). Escaping turns < into &lt;, so the browser shows the character instead of opening a tag.

Template engines do it for you: Angular and React bindings, Twig and Blade {{ }}, PHP htmlspecialchars(). Escape by hand when you build HTML in a string, an e-mail, an RSS feed or a page that shows code.

The five characters to escape

CharacterNamedNumericWhy
&&amp;&#38;starts an entity
<&lt;&#60;opens a tag
>&gt;&#62;closes a tag
"&quot;&#34;ends an attribute value in double quotes
'&apos;&#39;ends an attribute value in single quotes

In text, & and < are enough; in an attribute, the quote around its value must be escaped too, so always quote attributes. &apos; only exists since HTML5, so the tool writes &#39;, understood everywhere. Escaping does not make a javascript: link safe, nor text placed inside a <script>. Check URLs, and encode their parameters.

Named or numeric entities?

  • Named entities, such as &eacute;, are readable, but only some characters have one.
  • Decimal entities, such as &#233;, work for any Unicode character, emoji included.
  • Hexadecimal entities, such as &#xE9;, use the code point as written in Unicode tables (U+00E9).

With “Named”, the tool uses the name when the character has one and the decimal number otherwise. All three are understood by every browser.

Entities for accents: rarely needed

A page served in UTF-8, the default of HTML5 (<meta charset="utf-8">), can hold é, € or 👋 as they are: only the five special characters need escaping. Encode every character outside ASCII for channels limited to ASCII (some e-mail templates, old Latin-1 files), or to make invisible characters visible in the source.

EntityCharacterUse
&nbsp;non-breaking space, keeps “10 kg” on one line
&shy;soft hyphen, where a long word may break
&copy; &reg; &trade;© ® ™copyright and trademarks
&euro; &pound; &yen;€ £ ¥currencies
&ndash; &mdash;– —en dash (ranges), em dash
&hellip;…ellipsis
&laquo; &raquo;« »French quotation marks
&ldquo; &rdquo; &lsquo; &rsquo;“ ” ‘ ’curly quotes and apostrophe
&times; &divide; &plusmn;× ÷ ±arithmetic
&le; &ge; &ne; &infin;≤ ≥ ≠ ∞comparison, infinity
&larr; &rarr; &uarr; &darr;← → ↑ ↓arrows
&deg; &micro; &para; &sect;° µ ¶ §degree, micro, paragraph, section

To read a text full of entities, decode it.

Add this browser’s favorites to your account?

This browser has 0 favorites that your account does not have:

Either way, this browser keeps its favorites: you find them again after signing out.