How to use JSON Formatter
- 1. Paste or drop JSON. Paste a JSON document, or open / drop a file. The file is read in this tab — nothing is uploaded.
- 2. Validate the document. The parser runs as you type. Syntax errors appear in the status bar with the native engine message.
- 3. Pretty-print or minify. Choose 2-space or 4-space indentation, optionally sort keys, then copy or download the result.
- 4. Inspect structure. Use the stats line for character count, key count, and nesting depth before sending the payload onward.
About this tool
JSON (JavaScript Object Notation) is the default interchange format for APIs, config files, and browser storage. It is defined by RFC 8259 and by the ECMA-404 grammar. A formatter does not change meaning: it only changes whitespace so humans can read the document and machines can still parse it. PureDevKit’s formatter runs `JSON.parse` and `JSON.stringify` in your browser, which means secrets in a payload never cross the network.
What valid JSON actually allows
JSON is stricter than a JavaScript object literal. Keys must be double-quoted strings. Trailing commas are illegal. `undefined`, functions, comments, and single quotes are illegal. Numbers cannot have leading zeros (other than `0`) and cannot be `NaN` or `Infinity`. Strings are Unicode with a small set of escapes (`\n`, `\t`, `\"`, `\\`, and `\uXXXX`). Duplicate keys are syntactically allowed but the later value wins in `JSON.parse`, which is a common source of production bugs. If a document fails to parse here, it will also fail in `fetch().json()`, `json.loads` in Python, and `encoding/json` in Go.
Pretty-print vs minify
Pretty-printing inserts indentation and newlines so diffs and code review are readable. Minifying removes insignificant whitespace to reduce bytes on the wire. For most APIs the semantic content is identical; gzip often shrinks pretty JSON close to minified size, so pretty JSON is usually the right default in logs and fixtures. Minify when you are embedding JSON in a QR payload, a URL hash, or a size-limited cookie. Sorting keys is useful before committing fixtures: unordered objects produce noisy diffs even when values did not change. Sorting is not part of the JSON spec — it is a convenience for humans and for content-addressed hashing.
When validation is not enough
A document can be valid JSON and still be the wrong shape for your service. Schema tools such as JSON Schema, Zod, TypeBox, or OpenAPI check types, required fields, and ranges. Use this formatter to get to a clean document first, then convert it with the JSON to TypeScript tool or validate it against a schema in your test suite. Be careful with `JSON.parse` on huge documents: it must load the entire tree into memory. For multi-hundred-megabyte dumps, a streaming parser is more appropriate than a browser tab.
Privacy notes for payloads
Developers often paste access tokens, session cookies, and PII into online formatters. Hosted tools that run on a server can log that data even if they claim not to. PureDevKit never sends the document anywhere: formatting happens with the platform JSON engine already in your browser. Prefer local tools whenever the payload could identify a person or authorize an API.
Code examples
JavaScript
const payload = JSON.parse(raw);
console.log(JSON.stringify(payload, null, 2));Python
import json
print(json.dumps(json.loads(raw), indent=2, sort_keys=True))Go
var buf bytes.Buffer
if err := json.Indent(&buf, []byte(raw), "", " "); err != nil {
log.Fatal(err)
}