ToolBrigadeToolBrigade

JSON Formatter

Format, validate, and minify JSON data instantly.

How to use this tool

  1. 1Paste your raw or minified JSON into the left 'Input JSON' textarea.
  2. 2Click Format to pretty-print with 2-space indentation, or Minify to compact it into a single line.
  3. 3If the JSON is invalid, a red error message appears below the buttons describing the syntax problem.
  4. 4Copy the result from the right 'Output' textarea.

About JSON Formatter

This JSON formatter pretty-prints, validates, and minifies using the same parser your browser already trusts. Paste a single-line payload from a network log, inspect the nesting, fix a trailing comma, or compress the result back into an env var — all without installing another desktop plugin.

Invalid JSON can waste hours because the symptom looks like an application bug rather than a syntax error. Comparing two API responses is difficult when both are minified on one line. Config files checked into git without indentation are hard to review. This formatter gives you readable structure whenever you need it.

Paste into the input panel. Format pretty-prints with two-space indentation for a stable readable tree. Minify parses the same way and stringifies without extra whitespace for a single-line payload. Invalid input surfaces a red syntax error describing what the parser rejected — position clues included when the engine provides them. Copy from the output panel when it looks right. Everything stays local; your document never uploads.

Parser strictness is a feature. JSON does not allow trailing commas, single-quoted strings, undefined, or comments, even though JavaScript object literals do. Numbers outside MAX_SAFE_INTEGER may round if you round-trip through parse and stringify. Duplicate keys collapse to the last value per typical parse behavior. Pretty-print order follows enumeration after parse, which may not match original key order in every engine — do not use formatting alone as a cryptographic canonicalizer.

Debug a failing webhook body before you blame your handler. Prettify OpenAPI examples so reviewers can see nesting. Minify a hand-edited config before stuffing it into a CLI flag. Compare two pretty trees visually when a mobile client and web client disagree. Clean JSON copied from Slack that acquired smart quotes — after you fix the quotes, format confirms validity. Prepare fixtures for unit tests with consistent indentation.

Long-tail searches — format json online with error message, minify json for env variable, validate json parse error line, pretty print api response json — match this workflow. It is not a JSON Schema validator, not a YAML converter, and not a database. It formats and checks syntax.

JSON5 or HJSON features are unsupported. Extremely large documents can freeze the tab while the main thread parses — split them if the UI stalls. Binary data must be Base64 strings inside JSON; raw bytes do not belong here.

Treat production secrets carefully. Formatting tokens or PII in a shared screen-share still exposes them to viewers, even though this page does not exfiltrate the text. Clear the panels when you finish.

When an error cites an unexpected token, resist the urge to add braces at random. Copy the payload into the formatter, read the first reported issue, and fix only that. Then format again. Most nested JSON disasters are one missing comma away from clarity, but shotgun edits create new faults.

For teaching, show juniors a valid pretty document, minify it, then introduce a trailing comma and watch the error appear. That short loop builds intuition faster than a slide about RFC 8259. Keep sample documents free of real secrets even in internal workshops.

Code examples

JavaScript

// Pretty-print
const pretty = JSON.stringify(JSON.parse(raw), null, 2);

// Minify
const minified = JSON.stringify(JSON.parse(raw));

Python

import json

pretty = json.dumps(json.loads(raw), indent=2)
minified = json.dumps(json.loads(raw), separators=(',', ':'))

Frequently asked questions

The browser JSON.parse rules are strict: double quotes only, no trailing commas, no comments, no bare undefined. Smart quotes from chat apps also invalidate strings. Read the red error text for the first failure the parser hit. Fix that issue, then format again—cascading errors often disappear after the first repair.

Empty or whitespace-only input cannot parse as JSON and should surface a validation error rather than silent success. That failure mode is intentional so you do not copy a blank thinking it is valid. Paste a real document or a minimal object like {}. Treat empty format attempts as a scenario check for the error path.

No. Truncated payloads are invalid and will not parse until you restore missing braces or quotes from the source system. The tool reports the syntax problem; it does not invent closing tokens. Grab a complete body from your logging pipeline, then format. Guessing closers is a common scenario that still yields wrong data even if parse suddenly succeeds.

Formatting and minifying prove syntactic legality via JSON.parse. Schema validation proves semantic shape: required fields, types, and enums against a contract. Use this tool first to ensure the document parses. Use a schema validator when you need to enforce API contracts beyond braces and commas.

Pretty print helps humans review nesting and diffs in pull requests. Minify reduces size for embedding in query strings, env vars, or high-volume logs where whitespace is waste. Many teams keep pretty files in git and minify at build or deploy time. Choose based on audience: eyes versus machines.

Numbers outside the safe integer range can round when parsed as JavaScript numbers. Key order after stringify usually follows the parsed object enumeration, which may differ from the original text in edge cases. If you need bit-perfect canonical JSON, use a dedicated canonicalization library. Spot-check critical numeric IDs after a round trip.

Standard JSON.parse rejects comments. Strip // or /* */ comments before pasting, or convert from a JSONC-aware toolchain first. Seeing a parse error on an otherwise familiar VS Code settings file is a classic scenario. Remove comments, then format to confirm the remainder is pure JSON.

Parsing and stringifying run in your browser session without a required upload step for the core format and minify actions. That keeps customer payloads off someone else's disk. You remain responsible for who can see your screen and clipboard. Clear sensitive output when the debugging session ends.

Syntax validity does not imply schema validity. Missing fields, wrong types, or failed auth can still error after a perfect parse. Use schema checks and application logs for those failures. Seeing a green format result only means JSON.parse accepted the text, not that your API will.

Related Tools