Free Online JSON Formatter & Validator

Prettify • Minify • Validate • Sort Keys • Extract Paths

Format and validate JSON instantly. This JSON formatter runs entirely in your browser - no uploads.
Prettify, minify, sort keys, extract values by path, and optionally validate against a JSON Schema subset.
Find (in input)
Extract path
Options
Output / Diff / Schema
Output updates when you prettify/minify/sort/extract. Diff compares current input vs last snapshot.
JSON Schema (subset) - optional
Schema tools
Supports subset:
• type, enum, const
• required, properties, items
• min/max (number), minLength/maxLength
• minimum/maximum

About this tool

JSON (JavaScript Object Notation) is a lightweight, human-readable data format used almost everywhere: REST APIs, configuration files, webhook payloads, database exports, and log streams. Its simplicity is its strength, but it is also unforgiving — a single misplaced comma, an unquoted key, or a trailing bracket will cause a parser to reject the entire document. This JSON formatter parses your input using the browser's native JSON.parse(), which implements the ECMA-404 specification exactly. Any input that passes validation here is guaranteed to be valid JSON.

Beyond validation, the formatter provides four transformation modes. Prettify adds indentation and line breaks so nested structures are readable at a glance. Minify strips all whitespace to produce the most compact version for wire transfer or storage. Sort keys alphabetizes every object's properties — useful when comparing responses across API versions or making diffs meaningful. Extract path lets you drill into a specific nested field without manually scanning hundreds of lines.

Real example

Input (minified API response):

{"user":{"id":42,"name":"Alice","roles":["admin","editor"]},"active":true}

After clicking Prettify:

{
  "user": {
    "id": 42,
    "name": "Alice",
    "roles": [
      "admin",
      "editor"
    ]
  },
  "active": true
}

To extract just the user's name, enter user.name in the Extract path field and click Extract — the output will be "Alice". To extract the first role, use user.roles.0.

When to use this tool

Use the JSON Formatter whenever you are working directly with raw JSON data and need to inspect, validate, or transform it before the next step in your workflow. Common scenarios include debugging API responses that your application is rejecting, verifying a webhook payload matches what your handler expects, preparing a test fixture by minifying a large sample document, or making a configuration file readable before committing it to version control. The sort-keys feature is particularly useful before running a diff — without sorted keys, JSON objects can have the same values but appear different because key order is implementation-defined.

Common mistakes

  • Trailing commas: {"key": "value",} is valid JavaScript but invalid JSON. The spec does not allow a comma after the last element in an object or array. This is the most common cause of "valid-looking" JSON failing strict parsers.
  • Single quotes: JSON requires double quotes around both keys and string values. {'key': 'value'} is not JSON — it is a JavaScript object literal. Always use double quotes.
  • Comments: JSON has no comment syntax. // this is a setting or /* block comment */ will cause parse failures. If you need annotated config files, consider JSONC (JSON with Comments) or YAML, and strip comments before feeding to a strict JSON parser.
  • NaN and Infinity: JavaScript allows NaN and Infinity as number values, but JSON does not. If your code serializes these values, they become null in standard JSON output — or cause a serialization error depending on the library.
  • Unescaped control characters: Literal tab and newline characters inside a JSON string are invalid. They must be escaped as \t and \n. This often surfaces when copying multi-line text directly into a JSON value field.

Practical use case

A backend service is returning a 400 error on a POST request. The request body is JSON, built by string concatenation in a script. Paste the raw body into the formatter and hit Prettify — if parsing fails, the error message will point to the exact character offset where the syntax breaks. Once the structure is valid, use Sort Keys to normalize the output, then copy it into the Diff Checker alongside the expected payload to confirm every field and value is correct. This catches mismatched quotes, wrong nesting, and missing required fields before a single line of application code is changed.

FAQ

Does this send JSON to a server?
No. Formatting, validation, and all transformations run entirely in your browser using JavaScript. Your data never leaves your device. There is no server-side component, no account required, and no upload step.

Can it handle large JSON files?
Yes, up to your browser's available memory. Files in the tens of megabytes format without issues on modern hardware. For very large payloads (hundreds of megabytes), consider using a streaming parser in your terminal — jq . file.json handles arbitrarily large inputs without loading the full document into memory.

Why does "validate" fail when the JSON looks correct?
JSON is stricter than JavaScript object syntax. The most common hidden issues are: trailing commas after the last property, single-quoted strings, comments embedded in the document, and unescaped special characters inside string values. The error message will show the character position — count from the start of the document to identify the problem character.

What does "sort keys" do exactly?
Sort Keys recursively sorts every object's properties in alphabetical (lexicographic) order. It does not affect arrays, only objects. The result is structurally equivalent JSON where key order is deterministic, which makes automated diffs and textual comparisons stable across different serializers.

How does JSON path extraction work?
Use dot notation to descend into nested objects: user.address.city. Use numeric indices to access array elements: items.0.name for the first item's name. For compatibility with RFC 6901 JSON Pointer syntax, you can also use forward slashes: /user/address/city. If the path does not exist, the tool returns an empty result rather than an error.

Related tools

  • JWT Decoder — inspect JWTs whose payload is Base64-encoded JSON
  • JSON Editor — edit and restructure JSON in a tree view
  • JSON to TypeScript — generate TypeScript interfaces from any JSON object
  • YAML Validator — validate YAML configs and see their JSON equivalent
  • Diff Checker — compare two JSON payloads line-by-line before and after changes