🔧 JSON String Escaper / Unescaper
Turn raw text into a safe JSON string value, escaping ", \, newlines and tabs, or paste an escaped value to get the original text back.
escaped for a JSON string (\", \\, \n, \t, control chars, \uXXXX)
How the json string escaper / unescaper works
Escaping runs the text through the same rules a JSON serializer uses: the double quote, backslash, newline, carriage return, tab and other control characters are replaced with their backslash escapes (\", \\, \n, \r, \t, \uXXXX), so the result can be dropped between the quotes of a JSON string. Unescaping does the reverse by parsing the text as a JSON string literal, turning \n back into a real newline and \uXXXX back into its character.
Paste the text that goes *between* the quotes, not including the surrounding quotation marks. Unescaping fails if the text contains a bare (unescaped) double quote or a lone backslash, because that is not a valid JSON string body, escape it first, or fix the stray character.
Frequently asked questions
How do I escape a string for JSON?
Replace the special characters, double quote, backslash, newline, carriage return, tab and other control characters, with their backslash escapes (\", \\, \n, \r, \t). This tool does it for you: paste the raw text and choose Escape.
Which characters must be escaped in a JSON string?
The double quote (") and backslash (\) must always be escaped, along with the control characters U+0000-U+001F (newline, tab, etc.). Forward slashes and non-ASCII characters may be escaped but do not have to be.
How do I unescape a JSON string?
Choose Unescape and paste the escaped body (without the surrounding quotes). The tool parses it as a JSON string literal, so \n becomes a real newline, \" becomes a quote and \uXXXX becomes its character.
Why does unescaping fail?
A JSON string body cannot contain a bare double quote or a lone backslash. Those must be escaped. If unescaping errors, the input has a stray " or \; escape it or remove it and try again.
Does it handle newlines and tabs?
Yes. Escaping converts real newlines to \n, carriage returns to \r and tabs to \t; unescaping turns them back into the actual whitespace characters.
Can you show a worked example?
The two-line text He said "hi" followed by a newline and a tab becomes He said \"hi\"\n\t as a JSON string body. Wrap that in quotes and it is a valid JSON value; unescaping the body reverses each escape back to the original characters.
Why is the forward slash sometimes written as \/?
JSON allows escaping / as \/, but it is optional, the character is legal unescaped. Some encoders do it so the sequence </script> can't break out of an HTML script tag. This tool leaves forward slashes as-is, and unescaping accepts either form.
How is JSON escaping different from escaping for HTML or a URL?
Each targets a different context. JSON string escaping uses backslashes (\n, \") to make text safe between quotes in JSON. HTML uses entities (<, &) to make text safe inside markup, and URLs use percent-encoding (%20). The same text needs a different escape for each, so use the tool that matches where the value will sit.
How are backspace and form feed escaped?
JSON gives them dedicated short escapes: backspace (U+0008) becomes \b and form feed (U+000C) becomes \f, alongside \n, \r and \t. Any other control character below U+0020 without a short form is written as a \uXXXX escape, which is how rarely-seen control bytes round-trip safely.