Dev · 108 tools · nothing uploads

JSON format / validate

Parse, validate and pretty-print JSON, with a clear parse-error message if it is broken. Runs on your device.

Input

Options

live

JSON format / validate parses a document, then prints it back indented, with indent at 2 spaces by default and 4 or tab available. Sorting keys alphabetically at every level is off until you switch sortKeys on. Numbers go through JavaScript, so an integer larger than 2 to the 53 does not come back intact.

Questions

What does it do with broken JSON?

It refuses and shows you why. The text is run through the standard JSON parser, and if that fails the tool reports "invalid JSON:" followed by the parser message, which usually names the position of the problem. Nothing is guessed at or repaired.

What are the options?

Two. Indentation is 2 spaces by default and can be 4 or a tab. Sort object keys is off by default; turn it on and every object at every level has its keys sorted alphabetically, arrays keep their order. The result is always pretty-printed with a trailing newline.

Does it accept comments or trailing commas?

No. It parses strict JSON, so a JSONC or JSON5 file with comments, trailing commas, single quotes or unquoted keys is rejected as invalid, with the parser message telling you where. Strip those first if you are formatting a config file that allows them; the tool refuses the document rather than repairing it.

What happens to duplicate keys?

The last one wins, silently. That is how JSON parsing works, so an object with the same key twice comes out with a single copy of it and no warning. If duplicates matter to your data, check for them before formatting.

Will it change my numbers?

It can. Values pass through JavaScript numbers, so an integer beyond 2 to the 53 loses precision, 1.0 comes back as 1, and 1e3 comes back as 1000. Text and structure are untouched; only the way numbers are written can change.

Can I format several files at once?

Yes, drop as many as you like and each gets its own result block with its own Copy button. All of it runs in a Web Worker on your device, so an unreleased config or a payload with real customer data never leaves the tab. The same indentation and sorting options apply to every file in the batch.

Related Dev tools

n→nJSON sort / minify / escapeSort object keys, minify to one line, or escape/unescape JSON for embedding inside another string.Runs on each file you dropn→nJSONPath queryQuery JSON with a JSONPath expression: dot/bracket access, wildcards (*), recursive descent (..). No filter expressions (?()) or slices; those need a full JSONPath engine this build does not have.Runs on each file you dropn→nJSON Schema generatorInfer a draft-07 JSON Schema from an example JSON document. Every observed key is marked required, arrays are typed to accept every observed element.Runs on each file you dropn→nJSON to TypeScriptJSON to TypeScript. Infers types from an example JSON document. Nested objects become named types by their key; mixed-type arrays fall back to a broad/any type.Runs on each file you dropn→nJSON to GoJSON to Go. Infers types from an example JSON document. Nested objects become named types by their key; mixed-type arrays fall back to a broad/any type.Runs on each file you dropn→nJSON to RustJSON to Rust. Infers types from an example JSON document. Nested objects become named types by their key; mixed-type arrays fall back to a broad/any type.Runs on each file you dropn→nJSON ↔ CSVConvert a flat JSON array of objects to CSV and back. CSV has no type system: JSON->CSV renders numbers/booleans/null as text and CSV->JSON always comes back as strings. A nested object or array field is refused by name rather than silently flattened. CSV parsing is fully quote-aware, embedded newlines included; a file with an unterminated quote is refused rather than guessed at.Runs on each file you dropn→n.env ↔ JSONConvert a .env file to a flat JSON object and back. Values are treated as strings both ways. No nesting, no type coercion of numbers/booleans on the JSON->env direction beyond JSON.stringify.Runs on each file you drop