JSON Formatter and Validator

This tool formats and validates JSON (JavaScript Object Notation) entirely in your browser, so you can quickly turn messy or minified data into clean, readable text and catch syntax errors before they cause problems in your code, API calls or configuration files. Paste any raw or minified JSON into the input box, choose an indentation size of 2 spaces, 4 spaces or a tab, then click Format / Validate to pretty-print it with proper line breaks and indentation, or click Minify to strip all whitespace down to the smallest possible string. The status bar tells you straight away whether your JSON is valid, and if it is not, it reports the exact error message from the browser's parser, including the position of the first invalid character, so you can fix issues like trailing commas, single quotes or missing brackets. Below that, a statistics panel shows the validation status, the number of top-level keys or array items, the input size and the formatted output size in characters, giving you a quick sense of how your data is structured. A Copy Output button lets you grab the result straight to your clipboard. Because everything runs client-side using the browser's built-in JSON.parse() and JSON.stringify(), no data you paste is ever sent to a server, stored or logged, which makes this suitable for JSON containing sensitive information such as API keys or tokens.

Calculate.co.nz is proud to be partnered with realtor.co.nz, a trusted resource for navigating the New Zealand property market. Their Helpful Articles section offers clear, well-structured insights across buying, selling, and building, making complex real estate topics more accessible. With a focus on up-to-date guidance and practical knowledge, they empower Kiwis to move forward with clarity and confidence in a constantly evolving property landscape.
Calculate.co.nz partner: realtor.co.nz
Advertise on this page
Browser-side tool  Uses the browser's native JSON.parse() which implements ECMA-404 / RFC 8259.

1. Paste Your JSON

2. Formatted Output

Valid JSON. Formatted successfully.
{ "name": "Alice", "age": 30, "active": true, "scores": [ 95, 87, 100 ] }

JSON Statistics

Status
Valid
Keys (top level)
4
Input size
60 chars
Formatted size
95 chars

How JSON Formatting Works

JSON (JavaScript Object Notation) is a lightweight text format for exchanging structured data. It is defined by ECMA-404 and RFC 8259. The format consists of two structures: objects (collections of key-value pairs enclosed in curly braces) and arrays (ordered lists enclosed in square brackets). Keys must be strings enclosed in double quotes, and values can be strings, numbers, booleans (true / false), null, nested objects, or arrays.

Formatting (also called pretty-printing or beautifying) adds newlines and indentation to make JSON easier to read. Minifying removes all whitespace to produce the smallest possible string, which is useful for reducing file sizes in APIs and config files. This tool uses the browser's native JSON.parse() to validate and then JSON.stringify() with an indent argument to produce formatted output.

Worked Example

Given the following minified JSON input (the default in this tool):

{"name":"Alice","age":30,"active":true,"scores":[95,87,100]}

With 2-space indentation selected, the formatter produces:

{ "name": "Alice", "age": 30, "active": true, "scores": [ 95, 87, 100 ] }

The input has 4 top-level keys, an input size of 60 characters, and a formatted size of 95 characters.

Common JSON Errors

When to Use JSON vs Other Formats

JSON is the default data exchange format for REST APIs, web browser storage (localStorage, sessionStorage), and configuration files for Node.js projects and many modern tools. For configuration files that benefit from comments, YAML or TOML are popular alternatives. For binary efficiency over the wire, formats such as MessagePack or Protocol Buffers are used. For human-authored config where schema validation matters, JSON Schema can be layered on top of JSON.

Related Tools

Method: Validation and formatting use the browser's built-in JSON.parse() (ECMA-404 / RFC 8259) and JSON.stringify(indent). No server-side processing. Input size is measured in UTF-16 code units (same as JavaScript's String.length).

This tool processes all data locally in your browser. No input is transmitted or stored anywhere. Suitable for sensitive JSON content such as API keys, tokens, and configuration data.

Related calculators