Format Code Now
/

Unstringify JSON

FV-26

Paste a JSON value that was stringified, an escaped string in quotes, and get the original JSON back, formatted. Stringify does the reverse.

Runs in your browser. Nothing is uploaded.

A JSON string (in quotes), or JSON for Stringify

Result

How to use it

  1. Paste the quoted, escaped string, for example "{\"id\":1}".
  2. Choose the indent.
  3. Click Unstringify. If the string was stringified several times, it is unwrapped as far as it goes.
  4. To go back, paste JSON and click Stringify.

What unstringify does

JSON.stringify turns a value into text, and stringifying text that is already JSON adds a layer of escapes: quotes become \" and backslashes double. Unstringify removes that layer. It parses your input as a JSON string, then parses the inner text as JSON and prints it formatted. If the inner result is again a string, it repeats, up to 10 layers. Large integers keep every digit.

When the inner text is not JSON, and stringify

If the string does not hold JSON, you get the unescaped text itself, so a string with \n escapes comes back with real line breaks. The input must be a double-quoted JSON string; a plain object gives an error saying it is not a string. Stringify minifies your JSON first, or formats it if you tick the option, and wraps the result as one string with all quotes and backslashes escaped.

Error messages and what to do

MessageWhat it meansFix
The input is JSON but not a stringThe input is an object, array or other value, so there is no string layer to remove.Paste a quoted string, or use the JSON formatter for plain JSON.
The input is not valid JSONThe text does not parse as a JSON string, for example because the quotes are single or missing.Wrap the value in double quotes and escape inner quotes.
Nothing to unstringifyThe input box is empty.Paste a stringified JSON value.

Questions people ask

What does unstringify JSON mean?

It means reversing JSON.stringify on text that already held JSON: removing the outer quotes and escape characters so that you get the original object or array back, readable and indented.

Why is my JSON full of backslashes?

It was stringified, probably more than once. Each layer escapes the quotes of the previous one, so you see \" and \\. Unstringify removes the layers one at a time, up to 10, and prints the JSON underneath.

What if the string does not contain JSON?

You get the unescaped text instead of an error. A string such as "Line one\nLine two" comes back as two real lines. Only a quoted string is accepted as input.

How do I stringify JSON?

Paste the JSON and click Stringify. The JSON is minified, or formatted if you tick the option, and wrapped as one escaped string you can store in another JSON field or paste into code.

Are large numbers kept exact?

Yes. Numbers are copied as written when the inner JSON is printed, so 12345678901234567890 does not turn into 12345678901234567000, which is what a JavaScript number would do.

About this tool

Unstringify expects a JSON string in double quotes. It removes the quotes and escapes and, if what is inside is JSON, prints it formatted. If the result is itself a quoted string, it repeats, up to 10 layers, which handles JSON that was stringified more than once. If the inner text is not JSON, you get that text unescaped. Stringify minifies your JSON first and then wraps it as a string, with every quote and backslash escaped. Numbers are kept as written, so large integers are not rounded. Single-quoted or unquoted input is not accepted.

Format Code Now: free, no ads, no accounts. Your input stays in your browser.