Skip to content

JSON Formatter & Validator

Pretty-print, validate, sort keys, or minify. Stays in your browser.

The formatter below uses the browser’s native JSON.parse + JSON.stringify, with optional alphabetical key sorting and configurable indentation. Syntax errors surface with line and column where parsing failed. Nothing leaves the page — no analytics, no server-side processing of your payload.

97 chars

+54 bytes (longer)

How to use

  1. Paste JSON

    Any object, array, primitive, or mixed payload. Whitespace and trailing commas are not allowed by the spec; the formatter will flag them.

  2. Pick format / minify

    Format: pretty-print with 2 or 4 spaces or tabs. Minify: collapse to a single line for transport.

  3. Toggle sort keys (optional)

    Sorts every object's keys alphabetically, recursively. Useful for normalising diffs across two JSON files.

Frequently asked questions

Does this support JSON5 or JSONC (with comments)?
No — only strict RFC 8259 JSON. JSON5 (trailing commas, unquoted keys, comments) and JSONC (just comments) need their own parsers; the browser's native JSON.parse rejects them. For config files in those formats, strip the comments first or use a JSON5 parser.
What's the maximum file size?
Browser memory limit, typically tens to hundreds of MB. For multi-GB log files, use a streaming tool like jq from the command line.
Does it preserve number precision?
Numbers are parsed as IEEE 754 doubles — ~15-17 significant digits. Very large integers (e.g. a 64-bit Twitter snowflake ID) lose precision. For exact integer preservation, work with the JSON as text or use a BigInt-aware library; the browser's JSON.parse cannot help.
What does sort keys actually do?
Walks every object recursively and rewrites its key order alphabetically. Arrays are left in source order — JSON arrays are positionally meaningful. The output is byte-equivalent to the input semantically; only key order changes.
Why does my JSON show 'unexpected end of input'?
Usually a missing closing }, ], or " somewhere earlier. The reported line is where the parser ran out of input; the actual error is usually higher up. Look for unbalanced braces or open string literals.

About

What's valid JSON, exactly?

RFC 8259 (2017) is the current spec. Objects, arrays, strings, numbers, true / false / null. No comments. No trailing commas. No unquoted keys. No single-quoted strings. Keys must be strings. Strict on all of it. JavaScript object literals look similar but aren't the same thing.

When to use this vs jq, jless, etc.

This widget is the right tool for: ad-hoc validation, format/minify, normalising JSON across two sources for diffing. For interactive querying, transformation, or large files, jq (CLI) and jless (TUI) are more appropriate. For pretty-printing inside an editor, most modern editors have JSON formatters built in.