String Escape

Escape strings for many languages.

About the String Escape

Unescapes a JSON string back to plain text, decoding \", \\, \/, \n, \r, \t, \f, \b, and \uXXXX exactly the way JSON.parse does, and escapes raw text in the other direction so it can sit inside a JSON string. The same escapes mean the same thing in JavaScript, TypeScript, Java, C#, Go, and C, so one pass covers a payload and a source literal alike. Nothing is uploaded.

How to use the String Escape

  1. Paste the raw text into the input panel, or press Sample to load an example.
  2. Press Escape to produce a literal body, or Unescape to turn one back into raw text.
  3. Press Copy, or Download to save escaped.txt.

Frequently asked questions

How do I unescape a JSON string?
Paste the escaped body without its surrounding quotes and press Unescape. It decodes \", \\, \/, \b, \f, \n, \r, \t, and \uXXXX, and returns exactly what JSON.parse returns for the same string, surrogate pairs such as \ud83d\ude00 included.
Is the escaped output the same as JSON.stringify?
For a double quote, a backslash, a newline, a carriage return, a tab, a form feed, and a backspace it is byte-identical to the body JSON.stringify produces, and accented characters and emoji pass through untouched in both. It diverges on the other control characters below U+0020: JSON.stringify writes those as \u00XX, while this tool leaves the raw character in place.
Why does Unescape not fail on a half-escaped paste?
Because an escape it does not recognise, \q for example, is kept literally instead of throwing the way JSON.parse does. A log line where only some of the backslashes were ever escaped still comes back readable rather than failing outright.
Does the output include the surrounding quotes?
No. You get the body of the string, so the quotes already in your JSON or your source file stay where they are. Double quotes inside the text are escaped to \", which is the omission that breaks a payload.
How is this different from JSON Escape?
JSON Escape is JSON.stringify and JSON.parse directly, so it also escapes every remaining control character as \u00XX and refuses an escape sequence JSON does not define. This page covers the named C-style escapes that JSON, JavaScript, TypeScript, Java, C#, Go, and C share, and is the more forgiving of the two when unescaping.

Related tools