$ exec json
JSON Formatter
Use the format tab to pretty-print, minify, or sort JSON — or the compare tab (or “second JSON” on the format tab) to diff two documents side by side. Invalid JSON still reports exact line and column.
output will appear here.
$ cat about.md
JSON (JavaScript Object Notation) is the ubiquitous data format for REST APIs, configuration files, log records, and inter-service messaging. Despite its simplicity, it’s common to receive JSON that is one giant minified line, has inconsistent key ordering, or contains a sneaky trailing comma that breaks strict parsers. This formatter handles all three cases without requiring you to leave the browser.
The widget runs four operations: pretty-print (default 2-space indentation), minify (collapses to a single line — useful for embedding in code), sort (alphabetises object keys recursively, which makes diffing two API responses trivial), and diff (structural comparison — paste two JSON documents separated by a line containing only ---). Validation uses the browser’s built-in JSON.parse, so the parsing rules match what your application will see at runtime. When parsing fails, the tool extracts the byte position from the error message and shows the offending line with a caret pointing at the column.
Because the work happens in your browser, there is no upload limit beyond what your tab can hold in memory — comfortably tens of megabytes on a desktop. The tool also reports the byte size of the formatted output and the type of the root value (object, array, string, number, boolean, null), which is handy when you’re inspecting an API response and want a quick sanity check.
$ ls examples/
{"name":"karthick","skills":["java","go"]}Reformats minified JSON with 2-space indentation.
minify {"name": "karthick", "skills": ["java", "go"]}Collapses formatted JSON into a single line.
sort {"z": 1, "a": 2, "m": 3}Recursively sorts object keys — perfect for stable diffs.
{"name": "karthick",}Reports the trailing-comma error with line and column.
diff {"user":"a","count":1}
---
{"user":"a","count":2,"ok":true}Shows added keys, removed keys, and value changes between two JSON documents.
$ man --faq
Q.Does it support trailing commas or comments?
A.No. JSON.parse is strict per the JSON spec — trailing commas, comments, and unquoted keys all fail. If you need a relaxed parser, use JSON5 in your editor.
Q.Can it handle large files?
A.Yes, within the limits of your browser’s memory. Tens of megabytes are usually fine on a modern laptop.
Q.Why sort keys?
A.Sorted keys make diffing two API responses trivial because field order no longer matters. It’s also useful when generating canonical JSON for hashing or signing.
Q.Is my JSON sent anywhere?
A.No. The entire formatter runs in your browser — your data never leaves your device.
Q.How does it report errors?
A.When JSON.parse throws, the tool extracts the byte position from the error message, converts it to a line and column, and renders the offending source line with a caret marker.
Q.How do I compare two JSON blobs?
A.On this page, open the compare tab for two editors, or stay on format and turn on “second JSON (diff)”. In the ⌘K devtools panel you can still use json diff with a --- separator between two documents. Added fields are +, removed -, changed ~.