How to use the JSON Formatter & Validator
Pretty-print, validate, beautify, or minify JSON for API debugging, log inspection, code review, configuration files, and incident reports. The JSON Formatter parses the input strictly, reports the exact line and column of any syntax error, and lets you sort keys, control indentation, and hand off the cleaned output to JSONPath, CSV, YAML, or schema validation in one click. Everything runs locally in your browser — payloads stay on your machine.
What it does
- Prettify / beautify JSON with 2-space, 4-space, or tab indentation.
- Minify JSON to a single compact line for transport, environment variables, or storage.
- Validate JSON against the strict JSON spec — RFC 8259 — with line/column error pointers.
- Sort object keys alphabetically for stable diffs and reviewable artifacts.
- Detect common issues: trailing commas, single quotes, comments, unquoted keys, unescaped control characters.
- Copy, download, or send to JSONPath Tester, JSON to CSV, JSON ↔ YAML, or JSON Schema Validator.
When to use it
- Inspect a minified JSON log or API response.
- Prepare JSON for tickets, code reviews, or PR descriptions.
- Spot syntax errors before pasting into a config file or deploy pipeline.
- Produce stable, sorted output for diffs across service versions.
- Convert pasted JavaScript object literals into valid JSON for tooling.
- Compact a JSON payload for an HTTP header, query string, or env var.
How to use it
- Paste JSON into the editor (or load from clipboard / file).
- Pick an indentation: 2 spaces, 4 spaces, or tab.
- Click Prettify (or press Ctrl+Enter) to format. If the JSON is invalid, the error shows the exact line and a fix hint.
- Use Minify to collapse to one line; use Sort keys for stable diffs.
- Copy the result, download as a
.json file, or hand off to a related tool.
- For schema validation, send the formatted JSON to the JSON Schema Validator.
Tips & pitfalls
- Trailing commas, single quotes, and
// or /* */ comments are the most common parse failures — these are valid JavaScript but not valid JSON.
- Unquoted keys (
{key: 1}) are JavaScript, not JSON. Quote them: {"key": 1}.
- Special characters in strings must be escaped (
\n, \", \\).
- Sorting keys changes byte order but not meaning — only sort when you need stable diffs.
- Very large files may format slowly — for multi-megabyte logs, stream them through a CLI tool instead.
FAQ
- How do I beautify JSON online? Paste the JSON, choose an indentation, and click Prettify. The tool prints valid, indented JSON or shows a syntax error you can fix.
- How do I validate JSON? Paste it — validation runs automatically. Errors include the line and column where parsing failed and a description of the problem.
- What is the difference between minify and prettify? Prettify adds indentation and newlines for readability; minify removes all unnecessary whitespace for the smallest payload.
- Can I sort JSON keys alphabetically? Yes — the Sort keys option sorts object keys recursively so two semantically equal documents serialize identically.
- Is my JSON uploaded? No. Parsing and formatting run locally in your browser. Nothing is sent to a server or logged.
- Why does my JSON fail to parse? Most often: trailing commas, single quotes, comments, or unquoted keys — JavaScript object literals are not valid JSON. Fix those and try again.
- Can it handle JSON Lines (NDJSON)? Use the JSON Lines / NDJSON Viewer for newline-delimited JSON logs.
Runs locally in your browser. No uploads. Share links use an encrypted URL fragment.