Skip to content

String Escape and Unescape

Escape or unescape text for JSON, JavaScript, HTML, CSV, SQL and regular expressions.

Direction

Runs in your browser — nothing you enter is sent to a server.

How the String Escape and Unescape works

Choose the format your text is going into, then Escape or Unescape. The result updates as you type.

  • JSON and JavaScript: quotes, backslashes, line breaks and control characters get backslash escapes (\", \n). JavaScript also escapes single quotes.
  • HTML: &, <, > and quotes become entities.
  • CSV: a field with a comma, quote or line break is wrapped in quotes, and quotes inside are doubled.
  • SQL: single quotes are doubled (it''s).
  • Regex: characters with a special meaning, like . * ? ( ) [ ], get a backslash so they match literally.

Examples

The same text in six formats

She said "it's 5 < 6?" escapes to:

  • JSON: She said \"it's 5 < 6?\"
  • HTML: She said &quot;it&#39;s 5 &lt; 6?&quot;
  • SQL: She said "it''s 5 < 6?"
  • Regex: She said "it's 5 < 6\?"

Unescaping JSON

Line\nTab\té unescapes to "Line", a line break, "Tab", a tab and "é".

Frequently asked questions

Does SQL escaping prevent SQL injection?

Don't rely on it. Use parameterised queries (prepared statements) in your code; they keep data and SQL apart completely. Escaping is for writing one-off queries and fixtures by hand.

What is the difference between JSON and JavaScript escaping?

JSON strings are always in double quotes, so single quotes stay as they are. JavaScript strings can use either, so both are escaped.

Why does my unescape fail?

The text has an escape the format doesn't allow, such as a lone backslash at the end, an incomplete \u escape, or \x in JSON.

Is my text uploaded?

No. It is converted in your browser.

URL Encoder & Decoder

Percent-encode text for URLs and query strings, or decode %20-style encoded text back to readable text.

Developer Tools

Regex Tester

Test JavaScript regular expressions with live highlighting, groups and replacement.

Developer Tools