JSON Formatter, Validator and Converter

Format, minify and deep-sort keys, with syntax errors located by line and column — then convert to YAML or a TypeScript type. Nothing leaves this page.

Result

Nothing leaves this page — the site is static assets with no backend that could receive it.

The YAML direction is one-way on purpose: writing JSON as YAML is a closed problem, parsing arbitrary YAML back is not.

What is different here

Validation runs as you type; formatting is a button, because reflowing text under the caret moves it. Errors land on a line and column where that is possible: V8 usually supplies them and they are passed through; a bare character offset ("position 3184" tells you nothing about a minified payload) is converted; and for the message shape that reports only a snippet, the character is located only when it appears exactly once — guessing between candidates would be worse than saying nothing.

Sort keys is a deep sort, and its purpose is not tidiness: it makes two dumps of the same object diff cleanly. Two JSON files with the same content in a different key order show up in git diff as a wholesale rewrite.

The two conversions exist for what people do next after formatting. To YAML for moving a config between formats; to a TypeScript type for anyone about to consume the payload in code. Arrays become a union of their element shapes, and a null yields unknown | null — a null in the sample says the field is nullable, not that its type is null.

YAML is one-way on purpose. Writing JSON as YAML is a closed problem; parsing arbitrary YAML back (anchors, aliases, multi-document streams, implicit typing) is not, and a half-working importer is worse than none. For the same reason there is no parsing library here: a 40 KB dependency is not worth making every visitor download.

More tools