Format a JSON String as a JSON Document Online

How turning an escaped or minified JSON string into a formatted JSON document works, what it changes, and when it stays reliable after you copy or share it.

Short answer: is this conversion right for your task?

Converting a JSON string into a formatted JSON document is a good fit if you need to read, debug or review data that arrived escaped or squashed onto one line, such as a log entry, an API response embedded in another field, or a value copied from a database column. The main benefit is structure you can scan: nesting, keys and array items become visible. The key tradeoff is that most tools parse the data and then rewrite it. Parsing can quietly change some details, including very large numbers, the order of numeric-looking keys, duplicate keys and escape sequences. Keep the original plain text if the exact bytes matter, for example when you are verifying a signature, comparing hashes, storing evidence or sending data to a system that expects a single-line or escaped value.

What "JSON string to JSON" can mean

The phrase covers two different situations. Many tools handle both, but they are different operations, so it helps to know which one you have.

  • Minified JSON text: valid JSON with no line breaks or indentation. Formatting only adds whitespace between tokens.
  • Escaped (double-encoded) JSON: a JSON string literal whose content is itself JSON, wrapped in outer quotes with inner quotes written as ". It has to be decoded once to recover the inner JSON text, then parsed and formatted.

Searches for a way to "reverse JSON.stringify" usually mean the second case. In this context, "reverse" means decoding, which is what JSON.parse does in JavaScript. It does not mean reversing characters or mirroring text. Nothing about the order of characters or the shape of glyphs changes. The only changes are escape handling and whitespace.

What the transformation actually changes

Here is an escaped input of the kind often found inside logs or message payloads:

"{\"user\":{\"id\":7,\"tags\":[\"a\",\"b\"]}}"

Decoding it once removes the outer quotes and turns each " back into a plain quote, which gives ordinary minified JSON:

{"user":{"id":7,"tags":["a","b"]}}

Parsing that result and pretty-printing it with two-space indentation gives the following. This is the layout JavaScript's JSON.stringify produces with an indent of 2, with each array element on its own line:

{
  "user": {
    "id": 7,
    "tags": [
      "a",
      "b"
    ]
  }
}

The keys, values and nesting are the same as in the original. What changed is the stored characters themselves: escapes were removed and whitespace was added. This is not a visual effect like CSS styling. The formatted output is a different sequence of characters that happens to represent the same data. Whitespace inside string values is never touched, because it is part of the value.

Where a parse-and-rewrite can alter data

A formatter that parses the input and serializes it again can differ from the source in the ways below. These come from how common parsers are documented to behave. They are not results from testing any particular online tool, and this article does not show which tools are affected.

  • Large integers: JavaScript stores numbers as 64-bit floating point, so integers beyond about 2^53 lose precision. For example, 12345678901234567890 comes back as 12345678901234567000. Long numeric IDs are where this usually shows up.
  • Key order: JavaScript objects list integer-like keys first, in ascending order. So {"b":1,"10":2,"2":3} is re-serialized as {"2":3,"10":2,"b":1}. The data is equivalent, but a text diff will show changes.
  • Duplicate keys: the JSON specification does not define what parsers should do with them. JavaScript keeps the last value and silently drops the earlier ones.
  • Escape sequences: an escaped character such as \u00e9 may come out as the literal é, and an escaped slash / as a plain /. Some serializers go the other way. Python's json module escapes non-ASCII characters by default unless that option is turned off.
  • Non-standard input: comments, trailing commas, single-quoted strings and unquoted keys are not valid JSON. A strict tool will reject them, and a lenient one may silently normalize them.

If any of these would matter for your data, use a formatter that only re-indents the text without parsing it into native values. Otherwise, compare the output against the source before relying on it.

Doing the same conversion locally

You can do the same conversion without an online service, which also avoids sending the data anywhere. In a browser console or Node.js, with the escaped text (including its outer quotes) held in a variable named input:

const inner = JSON.parse(input);   // decodes the string literal to JSON text
const doc = JSON.parse(inner);     // parses that text into data
console.log(JSON.stringify(doc, null, 2));

With Python, reading the escaped text from standard input:

python3 -c 'import json,sys; print(json.dumps(json.loads(json.loads(sys.stdin.read())), indent=2, ensure_ascii=False))'

For input that is already plain minified JSON, python3 -m json.tool or jq '.' will pretty-print it, and jq's fromjson filter decodes an embedded JSON string. Python keeps large integers exact. Whether jq keeps them exact depends on the version, so check the documentation for the one you have.

Will the result stay usable after copying or sharing?

Formatted JSON is plain text, so in principle it copies cleanly. In practice, whether it survives depends on where you paste it, and no specific destination was tested for this article. Problems are most likely in places that treat text as prose instead of code.

  • Quote substitution: some word processors and messaging apps turn straight quotes into curly "smart" quotes, and curly quotes make JSON invalid. A code block or plain-text field is safer.
  • Whitespace handling: some rich-text fields collapse leading spaces or convert indentation. The data is still valid because whitespace between tokens has no meaning in JSON, but the readability gain is lost.
  • Tabs vs. spaces: indentation can look different from one editor to another. Spaces display more consistently.
  • Re-embedding: to put the document back into a field that expects a JSON string, such as an environment variable, a message payload or a log line, you have to minify and escape it again. Pasting the multi-line version there usually breaks the surrounding format.
  • Search and diffs: tools that search or diff text line by line treat the minified and formatted versions as completely different, even when the data is identical.

Keep the plain, single-line original when the destination requires a compact or escaped value, when exact bytes matter, or when you need to search a log for the exact original line.

Accessibility

Indentation mainly helps sighted readers follow the nesting. How screen readers announce indented code depends on the reader, its settings and the application showing the text, and no assistive technology was tested for this article. If you are sharing structured data with someone who uses a screen reader, a short prose summary of the key fields, or a table for flat data, can be clearer than the raw document. Reading order is unaffected, because formatting does not reorder or flip any characters.

Privacy and handling sensitive data

No evidence was available about how any particular online formatter stores, logs or transmits what you paste. A tool's design or wording such as "secure" or "runs in your browser" does not show what it actually does. Read the tool's documented data handling or check its network activity yourself. For data that contains credentials, tokens or personal information, use one of the local methods above instead of an online service.

Gaps in this review

  • No specific online tool was evaluated, so this article makes no claims about any tool's features, accuracy, limits or pricing.
  • No paste destinations were tested. The copy-and-paste risks above are general patterns, not confirmed results for any named app.
  • Screen reader behavior with formatted JSON was not tested.
  • The number precision and key ordering notes describe JavaScript-based parsing. A tool built on a different parser may behave differently.