DevTools Logo

JSON Formatter

JSON Formatter & Validator

Format, validate, and minify JSON. Errors point to the exact line and column.

Runs in your browser
Try an example

JSON input

Output

Paste JSON or load an example

Formatting runs in your browser. Nothing is uploaded.

More examples

Formatting Minified JSON

Input:
{"name":"Alice","age":30,"city":"New York"}

Output:
{
  "name": "Alice",
  "age": 30,
  "city": "New York"
}

Converts a compact, single-line JSON string into a human-readable format with indentation.

Validating and Formatting Complex JSON

Input:
[ { "id": 1, "items": [ "apple", "banana" ] }, { "id": 2, "active": true, "config": null } ]

Output:
[
  {
    "id": 1,
    "items": [
      "apple",
      "banana"
    ]
  },
  {
    "id": 2,
    "active": true,
    "config": null
  }
]

Formats nested arrays and objects with consistent indentation, handling different data types (number, string, boolean, null).

Detecting Syntax Errors

Input:
{
  "name": "Bob",
  "age": 40 // Missing comma
  "isStudent": false
}

The tool will identify the missing comma after the 'age' field and report a validation error.

    About this tool

    Paste JSON and the formatter validates it, then renders it in the mode you choose: Pretty with an indent you set — 2 spaces by default or a custom width — or Compact, which minifies everything onto a single line for production payloads. When parsing fails, the error message is matched to a line and column so you can jump straight to the offending character.

    Statistics update on every run: counts of objects, arrays, strings, numbers, booleans and nulls, the maximum nesting depth, and the formatted output's character, line and byte size. Beyond formatting there is a tree view for exploring structure, JSONPath queries for pulling matching values, text search with highlighting, and a compare pane that diffs your JSON against a second copy.

    The tool accepts strict JSON only: comments, trailing commas, single-quoted strings and unquoted keys are rejected exactly as a production parser would reject them. All parsing and analysis happen in your browser, so API responses containing real data stay on your machine.

    How to use this tool

    1. Paste or upload

      Paste JSON into the editor, upload a .json file, or start from one of the bundled samples.

    2. Choose a mode

      Pick Pretty for readability — adjusting the indent width if needed — or Compact to minify.

    3. Fix reported errors

      If validation fails, use the reported line and column to locate the syntax problem, correct it, and run the formatter again.

    4. Inspect the result

      Read the statistics, browse the tree view, run a JSONPath query, then copy or download the formatted output.

    Frequently asked questions

    Why is my JSON invalid?

    The usual culprits are a trailing comma before a closing bracket, single quotes around strings, comments, unquoted keys, or bare constants such as NaN. The JSON grammar allows none of these, and the validator reports the first position that breaks it.

    Can it minify JSON as well?

    Yes. Select the Compact mode and the output collapses to one line with no unnecessary whitespace — handy for shrinking configuration files or payloads before shipping them.

    Does it support comments (JSONC)?

    No. Validation follows the strict JSON specification, so JSONC annotations must be stripped first; otherwise the parser reports them as syntax errors just like any runtime would.

    Is my JSON uploaded anywhere?

    No. Parsing, formatting, statistics and comparisons all run in your browser with the standard JavaScript engine, and nothing is transmitted to a server.