devtools.cihat.dev

HTML entities and string escape

Make text safe to put inside HTML, read entity-filled text back as plain characters, or escape a string for JSON, JavaScript or SQL. The entity list below copies with one click.

What to do

Result

HTML entity list

Click an entity to copy it. Characters without a named entity show their number, which works everywhere.

Reserved in HTML

Spaces and invisible

Punctuation and quotes

Symbols and checkmarks

Arrows

Currency

Math

How to use it

  1. Pick encode, decode, escape or unescape and paste your text. The result updates as you type.
  2. For encoding, choose whether only the five reserved characters change or every non-ASCII character too. For strings, choose the language.
  3. Copy the result, or click any entity in the list to copy it.

Which characters must be encoded

Only five characters can break HTML: &, <, >, " and '. Encoding just those is enough for any page saved as UTF-8, and keeps accented and Turkish letters readable in the source.

  • Encode every non-ASCII character only when the text must survive a system that is not UTF-8, such as some old e-mail templates.
  • A named entity such as &rarr; and a numeric one such as &#8594; give the same character. Numbers work for every character; names exist only for some.
  • Encoding is for text you put into HTML. To show untrusted user input safely, encode it at the moment you render it, with your framework’s escaping.

Escaping strings for code

A string inside code needs a different escape from HTML. JSON writes quotes and control characters with a backslash (\", \n); a JavaScript single-quoted string escapes '; an SQL literal doubles the single quote (''). For SQL, prefer parameterised queries over escaping by hand.

Questions people ask

What is the HTML entity for a non-breaking space?

&nbsp; (or &#160;). It keeps two words on the same line and is not collapsed with other spaces.

What is the HTML code for a checkmark?

&check; or &#10003; gives ✓. The heavier ✔ is &#10004;, which has no name.

Does decoding run scripts in my text?

No. Decoding only turns entities into characters; tags stay as text and nothing is executed.

Is there an entity for the Turkish lira sign?

No named one. Use &#8378; for ₺, or type the character itself in a UTF-8 page.