Skip to main content
CaseSwitch

JSON Formatter

Use the CaseSwitch JSON Formatter to pretty-print messy JSON, minify valid JSON to one line, or catch parse errors before you ship a config. Paste a payload, choose Pretty print or Minify, and copy the result. Parsing runs in this browser — the payload is not uploaded.

Written by the CaseSwitch editorial team. We maintain these tools in the browser so drafts, keys, and images stay on your device.

Last reviewed: 30 August 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
}

Minify indented JSON

Input

{
  "name": "CaseSwitch",
  "ok": true
}

Output

{"name":"CaseSwitch","ok":true}

Nested objects and arrays

Input

{"users":[{"id":1,"tags":["a","b"]}],"ok":true}

Output

{
  "users": [
    {
      "id": 1,
      "tags": [
        "a",
        "b"
      ]
    }
  ],
  "ok": true
}

1.0 becomes 1 after parse

Input

{"n":1.0}

Output

{
  "n": 1
}

Invalid JSON (unquoted keys) — error, empty output

Input

{name: 'Ada'}

Output

(error: Invalid JSON — unquoted keys and single quotes are rejected)

How to use

  1. Paste the JSON into the input panel. Pretty print is the default mode.
  2. If you see a parse error, fix quotes, commas, and comments in the source, then paste again. The output stays empty until the input is valid.
  3. Switch to Minify when you want a single line. Copy or download the result.

What this tool is for

Pretty-print JSON for humans or minify it for transport. Developers paste API responses, config files, and localStorage dumps here to see structure — without sending payloads that may contain tokens to a third-party formatter. Pretty mode is for reading; minify is for size. Both require the input to be standard JSON first.

How it works

The input is parsed with JSON.parse. If parsing fails, you get an error and an empty output panel — the tool does not guess missing quotes or strip comments. Pretty print then runs JSON.stringify with the indent you choose (default 2 spaces, up to 8). Minify runs JSON.stringify with no extra whitespace. Duplicate keys: the parser keeps the last value. Numbers such as 1.0 become 1 in the output because JSON numbers do not keep a trailing decimal zero.

When to use it

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.

When not to use it

This is not a JSON Schema validator and not a merger of two documents. It does not accept JSONC (comments) or trailing commas from JavaScript object literals. Do not paste production secrets into a screenshot. Do not treat pretty/minify as a canonicalizer for cryptographic signing without a spec — number formatting can still differ across parsers.

How it compares to related tools

JSON Stringify escapes a string for embedding (adds quotes and backslashes). JSON Unstringifier reverses that. JSON to YAML is a different serialization. The JavaScript formatter is for source code, not data. Longer notes: Guide to JSON formatting.

Common mistakes

Assuming single quotes are valid JSON. Leaving trailing commas from a JS object. Pasting a Python dict with True/None/True. Minifying then pretty-printing in a loop until git history is noise. Expecting comments to survive — they will not; the parse fails.

Common JSON mistakes this parser will reject

Standard JSON requires double-quoted keys and strings, true/false/null in lowercase, and no trailing commas. Comments (// or /* */) fail. Single quotes fail. Python True/False/None fail. A trailing comma after the last property fails. Those inputs show an error rather than a “fixed” file. If you have JSONC from VS Code, strip comments in your editor first, or convert that file with a JSONC-aware tool — this page is strict JSON.

Pretty print versus minify

Pretty print adds indentation and line breaks so nested objects and arrays are visible. Minify removes insignificant whitespace so the payload is smaller for APIs, logs, and some test fixtures. Neither mode is meant to change the data model, but JSON numbers can lose a trailing .0, and key order follows what JSON.parse produced. Empty input is not valid JSON, so you will see an error until you paste a value, array, or object.

Frequently asked questions

Does this validate JSON?+

Yes, as a parse. If JSON.parse fails, you get an error instead of silently rewriting the file. That is not JSON Schema: it will not check required fields or types beyond what JSON itself allows.

What is the difference between pretty-print and minify?+

Pretty-print adds indentation and line breaks so humans can read the document. Minify removes unnecessary whitespace so the payload is smaller. Both require valid JSON first.

Does formatting change values?+

The object model is preserved. Number formatting can still change (1.0 becomes 1). Key order follows the parser. Do not use this as a canonicalizer for signatures without a spec.

Why is my JSON invalid?+

Common causes: trailing commas, comments, single quotes, unquoted keys, or a Python dict pasted with True/None. JSON requires double quotes, true/false/null, and no trailing commas.

Is JSON the same as a JavaScript object literal?+

No. Object literals may use unquoted keys, trailing commas, comments, and single quotes. This formatter only accepts JSON.

Is my JSON uploaded?+

No. Parsing and stringify run in this browser. You can disconnect after the page loads and still format or minify.

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 guides

Read our original articles on this topic.

Related tools