What String to JSON does
String to JSON reads a JSON-escaped string and writes it as JSON. The input is parsed first, so a syntax error is reported with its position instead of producing broken output.
String to JSON examples
The built-in sample
Input
{\"a\":1,\"b\":[true,null]}Output
{
"a": 1,
"b": [
true,
null
]
}This is the input that the Load sample button fills in.
With or without the surrounding quotes
Input
{\"a\":1,\"b\":\"x\\ny\"}Output
{
"a": 1,
"b": "x\ny"
}The input here has no outer quotes; the tool adds them and tries again. The escaped \\n inside the string is unescaped once and then appears as the JSON escape \n in the formatted result.
Each output was produced by running this tool on the input above it.
How it works
Reading a JSON-escaped string. The input is treated as a JSON-escaped string, with or without its surrounding quotes. It is unescaped, and if the result is itself JSON text it is parsed too, so a doubly encoded payload is recovered in one step.
Writing JSON. The result is written as JSON with two-space indentation.
Details and limits
- A value that was encoded twice is decoded twice: if the unescaped string is itself JSON text, that text is parsed.
- A plain word such as
hellois returned as the JSON string"hello", because any text is a valid string once it is quoted. - If the text cannot be read as a string either way, the tool reports "Not a valid JSON-escaped string". A common cause is text from which a log viewer has already removed one level of backslashes.
- Input that is not valid JSON stops the tool, and the status line shows where the problem is. The JSON Validator page lists the usual causes.
Questions
Is my data uploaded when I use String to JSON?
No. The tool runs in your browser, so what you paste or open is processed on your own device and is not sent to a server.
What does String to JSON do?
String to JSON reads a JSON-escaped string and writes it as JSON. The input is parsed first, so a syntax error is reported with its position instead of producing broken output.
How does String to JSON work?
Reading a JSON-escaped string. The input is treated as a JSON-escaped string, with or without its surrounding quotes.
Are there any limits I should know about?
A value that was encoded twice is decoded twice: if the unescaped string is itself JSON text, that text is parsed. A plain word such as hello is returned as the JSON string "hello", because any text is a valid string once it is quoted.
Is there a size limit?
There is no fixed size limit. Everything happens on your device, so very large inputs depend on its memory and can take longer on a phone than on a computer.
Does it work on phones, and is it free?
Yes. It works in any current browser on Android phones, iPhones, tablets and computers. It is free and needs no account or sign-up.