()
ℹ️ About JSON Processing
JSON (JavaScript Object Notation) is a text format for structured data made from objects,
arrays, strings, numbers, booleans, and null. It is the default payload format for REST APIs,
webhooks, configuration files, logs, and document databases because almost every language can parse it.
This JSON formatter parses the text you paste with a strict RFC 8259 parser, then pretty-prints it, minifies it, reports the first syntax error, or summarises its structure (key count, nesting depth, value types, sample paths). Use it to review compressed API responses, shrink request bodies, and check a config file before it is saved or committed.
Supported inputs
- One JSON text per run: an object, an array, or a lone string, number, boolean, or
nullat the top level. - Strict JSON only: double-quoted names and strings; no comments, trailing commas, single quotes,
NaN,Infinity, leading zeroes, or hex numbers. JSON5, JSONC, and JSON Lines are rejected. - Operations: Format/Pretty Print, Minify/Compact, Validate Only, Analyze Structure. Every operation validates first; invalid input yields an error and no output.
- Format options: indent with 2 spaces, 4 spaces, or a tab (the API accepts any space count from 0 to 10 as a string, for example
"3";"0"yields minified output andJSON.stringifycaps anything above 10 at 10 spaces), and Sort keys alphabetically, which sorts object keys recursively in code-unit order (uppercase and underscore before lowercase) and never reorders arrays. - Whitespace-only input counts as empty, not as an error.
- API body (POST, JSON):
json(aliasinput),operation(format,minify,validate,analyze),indent,sortKeys.
Output
- Validation status: Valid with the input's character and line count, or Invalid with the parser error, which names the offending token and, for most structural errors, its position (the API returns
sizeandlinesin both cases). - Format returns the document re-serialised with the chosen indent; Minify returns one line with all insignificant whitespace removed; Validate produces no output text, but the status line and the structure analysis for documents with object keys still appear; Analyze returns a JSON report with
structure_analysis,sample_paths(first 20),validation_status, andrecommendations. - Structure analysis (any valid document with at least one object key): total keys, maximum depth, array and object counts, a count per value type, and the largest array length. Documents nested deeper than two levels also get a JSON Paths list of the first 10 paths in dot and bracket notation, starting with the root marker
{}or[]and continuing with entries such asusers[0].metadata.lastLoginfrom the built-in sample. - Copy puts the output on the clipboard; Download saves it as a
.jsonfile. - The API returns
isValid,error,output,validation(isValid,error,size,lines),analysis, and the completejsonPathslist.
Example
Input {"user":{"id":42,"active":true},"roles":["admin","api"]} with Format and a
2-space indent produces:
{
"user": {
"id": 42,
"active": true
},
"roles": [
"admin",
"api"
]
}
The status line reports 56 characters and 1 line; the analysis shows 4 keys, maximum depth 2, 1 array, 2 objects, largest array 2 items. Minify returns the input unchanged because it already has no insignificant whitespace.
Limitations
- Syntax validation is not JSON Schema, OpenAPI, or business-rule validation; use the JSON Schema Validator for those.
- Nothing is repaired: comments, trailing commas, and single quotes are reported, not fixed, and only the first error is shown. The message text comes from the JavaScript engine's parser, so wording differs slightly between browsers.
- Output is a re-serialisation, not a byte copy: keys that look like array indexes (
"2","10") move to the front in ascending numeric order, a duplicate key keeps its first position with its last value, integers above 253 lose precision (12345678901234567890becomes12345678901234567000),1.0becomes1,1e2becomes100, and escapes such as\u0041or\/are written as literal characters. If exact bytes matter, for example for signed payloads, keep the original text and use the formatter for review only. - The path list is an inspection aid, not a JSONPath engine: keys containing dots are not quoted, and the page shows 10 paths (the analyze report 20, the API all). For queries use the JSON Path Evaluator; for JSON Lines use the JSON Visualizer.
- Very large documents are bounded by browser memory on the page and by server-side process limits per API request (about 128 KB of JSON, set by the process argument limit, and 5 seconds of execution); the API is rate limited to 60 requests per minute for anonymous callers.
Browser or server processing
Processing happens in your browser: the page loads the compiled logic module and runs it on every keystroke,
so the JSON you paste is never sent to a server and the tool keeps working offline once loaded. The public API
at /api/tools/format/json runs the same module on the server; only documents you deliberately
POST there leave your machine.
FAQ
Why does my JSON fail to validate?
Usually single-quoted strings or keys, a trailing comma after the last item, comments, unquoted keys, or
values such as NaN and undefined. These are legal in JavaScript or JSON5 but not in
JSON. The error names the offending token and, in most browsers, gives the position of the first structural
problem; fix it and the parser reports the next one, if any.
Does formatting change the key order?
Usually not. Ordinary keys keep their input order, but keys that look like array indexes ("2",
"10") are moved to the front in ascending numeric order by the JavaScript engine, and a duplicate
key keeps its first position with its last value. Enable Sort keys alphabetically for a
deterministic order. Arrays are never reordered.
Is my JSON uploaded to a server?
Not when you use the page: parsing, formatting, and analysis run entirely in the browser. Only requests you make yourself to the public API send the document to the server.
References
API Usage Example:
POST /api/tools/format/json
Content-Type: application/json
{
"json": "{\"name\":\"Alice\",\"age\":30,\"tags\":[\"x\",\"y\"]}",
"operation": "format",
"indent": "2",
"sortKeys": false
}