Friday, November 6, 2026 · Asia/KarachiFree tools · No signup · Runs in your browser

JSON Stringify

JSON stringify here takes JSON you already parsed in your head as text, parses it, and writes it back out in one of three shapes. Pretty indents with two spaces. Compact is a single line. Quoted wraps the pretty form in a string and escapes the inner quotes.

New

{"name":"Ada"} in pretty mode comes back with the name on its own line. {"n":1} in compact mode is {"n":1} with no extra space.

How to use

  1. Paste one JSON value.
  2. Choose pretty, one line, or quoted string.
  3. Press Stringify. Invalid JSON stops with the parser message. Reset restores the name object in pretty mode.

Formula / how it works

Three writers, one parse. The text is parsed once. If that fails, nothing is written and the error is the parser’s. Pretty uses two spaces. Compact uses the shortest form JSON.stringify produces, which keeps a space after a colon in some engines and not in others: this engine’s compact form of {"n":1} is {"n":1} with no space. Quoted mode stringifies the pretty text, so newlines become backslash-n and quotes become backslash-quote. That quoted result is what you paste into a log that stores JSON inside a string. The string to JSON tool parses that wrapping back off. The JSON parser stops at valid or invalid and does not reformat.

Order and types. Keys stay in the order they were parsed. Numbers stay numbers. A string that looks like a number stays a string because it was quoted in the input. This page does not sort and does not coerce. An array is an array. Null is null.

What you should copy. In quoted mode, copy the whole line including the outer quotes if you need the wrapping. In pretty mode, copy the indented value and leave the mode label behind if the destination is a file that must be raw JSON. The mode line is for you, not for a parser.

Pretty mode is for a person. Compact mode is for a log line. Quoted mode is for a value that must travel inside another string, which is the shape the string-to-JSON page unwraps. Round-tripping is a good check: stringify in quoted mode, then unwrap on the other page, and you should see the same keys. Key order follows the text you parsed. This page does not sort. Numbers stay numbers. A numeric string stays quoted.

A practical loop with the unwrap page is the best test of quoted mode. Pretty-print a small object, switch to quoted, copy the result, and unwrap it. The keys should match and the indent should come back. If they do not, you copied the mode label along with the body, or you dropped an outer quote. Compact mode is the one to paste into a query string only after you also percent-encode it. This page does not percent-encode. It only stringifies. Leaving that step out is how a brace breaks a URL. Keep a copy of the original one-line payload until the round trip matches, because pretty text is harder to diff by eye when only one key moved. If a reviewer only has the pretty form, ask them to compact it before they comment on whitespace.

Whitespace in pretty mode is part of the text you copy and not part of the data. Two files that differ only by indent still parse to the same value. Compact them before you decide they disagree. The mode label is never part of the data.

Worked examples

A name, pretty

Inputs: JSON: {"name":"Ada"} | Mode: pretty

Paste {"name":"Ada"} and leave the mode on pretty, then press Stringify. The name key is indented.

Result: Mode: pretty { "name": "Ada" }

A number, one line

Inputs: JSON: {"n":1} | Mode: compact

Paste {"n":1} and set the mode to compact, then press Stringify. The body is a single line.

Result: Mode: compact {"n":1}

Use cases

  • Indenting a one-line payload so you can read it.
  • Collapsing a pretty file to one line for a log.
  • Producing the quoted form that the unwrap tool accepts.
  • Checking that a number stayed a number.

Tips & limitations

  • Copy the body, not the mode label, into a JSON file.
  • Use quoted mode only when the next step expects a string.
  • Invalid JSON is not repaired.
  • Key order is the order you pasted.

FAQ

Does compact add a space after the colon?

Not for {"n":1}. The compact body is the engine’s shortest form of that object.

What is quoted mode for?

It wraps the pretty text in a JSON string and escapes quotes and newlines, so the value can sit inside another string.

Will keys be sorted?

No. They stay in parse order.

What if the text is not JSON?

The parse fails and the error is shown. Nothing is stringified.

Is this the same as the formatter?

The formatter has more modes, including a sort. This page is the three shapes above and nothing else.

Is the text uploaded?

No. Parse and stringify run in the browser.

Runs entirely in your browser; nothing is uploaded. Check the output before you rely on it in production code, data or security decisions.