JSON Stringify
Paste valid JSON, then re-serialize it with JSON.stringify and an indent of 0–8 spaces (default 2). Invalid JSON fails with a parse error — this is not a free-form text escaper. Parsing stays in this browser.
Written by the CaseSwitch editorial team. We maintain these tools in the browser so drafts, keys, and images stay on your device.
Last reviewed: 23 July 2026
Processed locally in your browser. Nothing is sent to a server.
Paste or type text to convert. Output stays empty until there is input.
Character count: 0 · Word count: 0 · Line count: 0
Examples
Pretty-print a compact object
Input
{"name":"CaseSwitch","ok":true}Output
{
"name": "CaseSwitch",
"ok": true
}Array with default indent
Input
[1,2,3]
Output
[ 1, 2, 3 ]
Nested object with indent 4
Input
{"a":{"b":[1,2]}}Output
{
"a": {
"b": [
1,
2
]
}
}JSON string value stays a quoted string
Input
"He said \"hi\""
Output
"He said \"hi\""
Invalid plain text — parse error
Input
He said "hi"
Output
(error: Invalid JSON — plain text without JSON structure is rejected)
How to use
- Paste a valid JSON value (object, array, string, number, true/false/null).
- Set indent spaces if you want something other than 2.
- Copy the re-stringified output, or fix parse errors in the source and try again.
What this tool is for
JSON.stringify with indent re-emits a valid JSON document as a stable string after JSON.parse. Use it when you need indent control for a payload, or when you are normalizing a compact object before a review. It requires real JSON first — not a raw unquoted sentence.
How it works
The input is parsed with JSON.parse. On success, JSON.stringify runs with your indent setting (default 2). Indent 0 still keeps structural commas but avoids pretty spacing the way a multi-space indent would. Invalid JSON fails with an error and an empty output panel. Numbers such as 1.0 become 1 after parse. Duplicate keys: the parser keeps the last value.
When to use it
Normalizing an API sample to a team indent, re-serializing a one-line fixture with 4-space indent, and checking that a paste is valid JSON before you commit it. If you only need pretty vs minify toggles, the JSON Formatter is the sibling tool. If you need to recover text from a quoted JSON string literal, use JSON Unstringifier.
When not to use it
Do not paste plain English without JSON quotes — parse will fail. This is not a schema validator. It does not accept JSONC comments or trailing commas. Do not treat stringify as encryption. For YAML output, use JSON to YAML.
How it compares to related tools
JSON Formatter adds an explicit Pretty / Minify mode switch. JSON Unstringifier decodes a quoted JSON string into raw text (newlines included). JSON to YAML changes serialization language. Longer notes: Guide to JSON formatting.
Common mistakes
Expecting raw text like He said "hi" to become a quoted literal — that input is invalid JSON here; wrap it as a JSON string first ("He said \"hi\""). Double-pasting already-stringified values. Assuming comments survive. Using this as a cryptographic canonicalizer without a spec.
Indent control vs the JSON formatter
Both this tool and the JSON Formatter parse with JSON.parse and write with JSON.stringify. The formatter emphasizes Pretty vs Minify as modes. JSON Stringify focuses on choosing an indent width for a valid document. Pick one workflow and stick to it in a PR so diffs stay boring. Neither tool repairs JSONC or JavaScript object literals.
String values vs whole documents
If the input is a JSON string (opening and closing quotes, with escapes), stringify writes that string value back as a quoted literal. If you need the decoded text with real newlines, use Unstringifier instead. If the input is an object or array, you get a pretty document. Plain unquoted text is not JSON and fails.
Frequently asked questions
Does this escape an arbitrary sentence into a JSON string?+
Not as a free-form text escaper. The input must already be valid JSON. To embed prose, wrap it as a JSON string literal first, or build the string in code with JSON.stringify in your runtime.
How is this different from the JSON Formatter?+
Same parse-and-print family. The formatter adds a Minify mode switch; this page centers on indent spaces for a re-stringified value.
What indent should I use?+
2 spaces is the common default for JSON fixtures. Some teams use 4. Match the repo, not this page.
Why did 1.0 become 1?+
JSON numbers do not keep a trailing decimal zero after parse. That is normal JSON behavior, not a bug in the indent step.
Can I stringify TypeScript or JS object literals?+
No. Unquoted keys, trailing commas, and comments fail. Use strict JSON.
Is my JSON uploaded?+
No. Parse and stringify run in this browser.
Does this tool send my payload to CaseSwitch?+
No. Formatting, encoding, and naming conversions for this page run in your browser after load — your sample stays on the device.
Related tools
JSON Unstringifier
Cleaning a message copied from a JSON log line, extracting body text from a quoted fixture field, reversing accidental double wrapping when you only need the inner string, and teaching how JSON string escapes work.
JSON Formatter
Debugging a 401 response, comparing two configs, preparing a gist, shrinking a JSON blob before embedding it in a test fixture, and checking whether a file is actually JSON before you commit it. If you need to escape a string as a JSON literal, use JSON Stringify instead. If you need YAML, use JSON to YAML after the JSON is valid.
JSON to YAML Converter
Turning a JSON API example into a values.yaml draft, comparing the same data in two syntaxes, and preparing a workflow fragment from a JSON fixture. Validate Kubernetes kinds and apiVersions separately.
CSV to JSON Converter
Fixture generation, prototyping a table UI, turning a small Sheets export into API-shaped JSON, and checking column names before wiring a mapper.
YAML Formatter
Cleaning a workflow file snippet, reviewing a Helm values fragment, normalizing list indentation, and teaching YAML structure on a short sample.