JSON Formatter & Validator — Pretty Print & Minify Online
What Is JSON and Why Does Formatting Matter?
JSON (JavaScript Object Notation) is a lightweight, human-readable data interchange format. It is the de facto standard for REST API responses, configuration files, and data serialisation across virtually every programming language. Well-formatted JSON is easy to read and diff; minified JSON is smaller to transmit. This tool lets you switch between both in one click.
Common JSON Errors to Watch For
- Trailing commas —
{"a": 1,}is invalid JSON (valid in JS but not JSON spec). - Single quotes — JSON requires double quotes for both keys and string values.
- Unquoted keys —
{name: "value"}is JavaScript object literal syntax, not JSON. - Missing or extra brackets — A mismatched
{or[causes the entire document to fail parsing. - Comments — Standard JSON does not support
// commentsor/* block comments */.
Common Use Cases
- API debugging — Raw API responses are often minified. Format them to inspect the structure.
- Configuration files —
package.json,tsconfig.json, and many other config files use JSON. - Data interchange — Validating a JSON payload before submitting it to an API endpoint.
Tips for Large JSON Files
For very large JSON files (megabytes+), browser-based tools can be slow. Consider splitting the file or using a CLI tool like jq for large-scale processing. For files under a few hundred kilobytes, this tool handles formatting instantly.
Why Format JSON Locally?
API responses often contain sensitive data — authentication tokens, user records, personal information. Pasting this into a server-backed formatter risks that data being logged. This tool uses JavaScript's native JSON.parse() and JSON.stringify() — no network request is ever made.
JSON in PHP
json_encode($array)— Converts a PHP array or object to a JSON stringjson_encode($array, JSON_PRETTY_PRINT)— Adds indentation and newlines for readable outputjson_decode($json, true)— Parses a JSON string into a PHP associative array (thetrueflag is key)json_last_error()— Returns the last JSON encoding/decoding error codejson_last_error_msg()— Returns a human-readable error message for the last JSON error
Laravel's response()->json($data) helper automatically calls json_encode() and sets the Content-Type: application/json header. For incoming requests, $request->json()->all() or $request->input() handles JSON payloads transparently.
Privacy & How It Works
All formatting and validation uses JavaScript's native JSON.parse() and JSON.stringify(). No JSON data is ever transmitted to any server.
- No server calls — Parsing and formatting run entirely in your browser.
- Works offline — Once the page loads, no internet connection is needed.
- GDPR-safe — Zero data collection, zero data transmission.