Free String Escape & Unescape Tool

Free string escaper: escape or unescape quotes, backslashes, newlines and special characters for JSON, JavaScript, Java/C#, HTML, XML, SQL, CSV, regex or URLs.

  • No upload, 100% private
  • Instant, in your browser
  • 100% free, no signup
Loading tool…
Read the complete guideHow String Escaping Works in JSON, JavaScript, HTML, SQL and Regex →

About the String Escape / Unescape tool

Special characters cause more bugs than almost anything else in everyday coding. A stray double quote breaks a JSON payload, an apostrophe ends a SQL string early, an unescaped less-than sign breaks HTML and a dot in a regular expression matches any character. Escaping text by hand for each language is fiddly, and unescaping a log line full of \n and \u00e9 sequences is worse.

This string escape tool converts text in both directions for nine formats: JSON strings, JavaScript strings, Java and C# strings, HTML, XML, SQL string literals, CSV fields, regular expressions and URL components. Choose a format, choose Escape or Unescape, and paste your text; the result updates as you type.

Each format follows its own rules. JSON escapes quotes, backslashes and control characters; Java/C# additionally turns non-ASCII into \uXXXX; HTML converts the five significant characters to entities; SQL doubles single quotes; CSV wraps fields containing commas, quotes or line breaks in quotes; and regex escapes every metacharacter. For JavaScript you can pick which quote style to escape.

How to use String Escape / Unescape

  1. Choose a “Format” such as JSON string, HTML or Regular expression.
  2. Select the “Escape” or “Unescape” tab.
  3. Paste your text into the input box, or click “Sample” to try it.
  4. For JavaScript, choose which “Quotes to escape” if needed.
  5. Copy or download the result from the output box.

Features

Nine formats

JSON, JavaScript, Java/C#, HTML, XML, SQL, CSV, regex and URL encoding in one place.

Two-way conversion

Every format can be escaped and unescaped, including \u, \x and octal sequences.

Unicode aware

Emoji and other astral characters become correct surrogate pairs in Java/C# mode.

Clear error messages

Malformed JSON escapes or percent-encoding are reported instead of producing garbage.

Live and local

Output updates as you type and your text never leaves the browser.

When to use it

  • Embed a multi-line HTML snippet inside a JSON config value.
  • Turn a user’s search phrase into a literal regular expression.
  • Read an escaped stack trace or log message copied from JSON logs.
  • Prepare text with apostrophes for a quick manual SQL insert.
  • Escape a string for a Java or C# unit-test fixture.

Frequently asked questions

Is doubling quotes enough to prevent SQL injection?

No. It is fine for quick manual queries, but application code should always use parameterised queries or prepared statements instead of building SQL strings.

What is the difference between JSON and JavaScript escaping?

JSON only allows double-quoted strings and a fixed set of escapes. JavaScript also supports single quotes, backticks and escapes like \x41, and needs \u2028 and \u2029 escaped in older engines.

Which characters must be escaped in HTML?

& and < in text, plus " or ' inside attribute values. This tool escapes all five (&, <, >, ", ') so the result is safe in both places.

How is URL encoding different from HTML escaping?

URL encoding replaces unsafe bytes with %XX codes for use in addresses, while HTML escaping uses entities like &amp; for use in page markup. They are not interchangeable.

Does unescape handle \u{1F600} style escapes?

Yes. The JavaScript and Java/C# unescape modes understand \uXXXX, \u{…}, \xXX, octal and the standard single-letter escapes.

Related tools