JSON Formatter & Validator

Paste your JSON to format, validate, or minify it.

About JSON Formatter

The JSON Formatter parses and validates your JSON data, then reformats it with configurable indentation for easy reading. Use Minify to compress JSON into a single line for production or API payloads. If your input contains errors, the tool highlights the exact location of the problem.

How to use

Paste your raw JSON into the input box, then click Format to prettify or Minify to compress it. Use the indent selector to choose between 2 or 4 spaces. The Sample JSON button loads example data if you want to explore the tool without your own input. Click Copy to copy the output to your clipboard.

Common use cases

  • API debugging — prettify minified API responses to read the structure at a glance.
  • Config files — validate and format JSON configuration files before deploying.
  • Data inspection — explore nested objects from logs, databases, or third-party webhooks.
  • Minification — compress readable JSON into a compact single-line format for smaller payload sizes.

About the JSON Formatter

A JSON formatter takes JSON data — minified, mangled, or hand-written — and re-emits it in a consistent, human-readable form with proper indentation and predictable property ordering. It also validates the input, surfacing the line and column of any syntax error so you can fix the problem at its source.

JSON has become the default data interchange format on the web. Every REST API, most configuration files, every JavaScript module bundler, and most logging pipelines speak JSON. Reading raw JSON from an API response or a log file is unpleasant: it is usually minified to save bytes, with no whitespace and no line breaks. Formatting restores legibility so you can actually find the field you are looking for.

Minify versus prettify

Prettifying adds whitespace, line breaks, and indentation. It is what you want when reading or editing JSON by hand. Minifying strips every non-essential byte. It is what you want when sending JSON over the wire or embedding it in a build artefact, where every kilobyte counts. This tool offers both: paste a minified blob to read it, or paste a hand-edited file to compress it for production.

Validation and error messages

JSON is strict: trailing commas, single quotes around strings, comments, unquoted property names, and NaN/Infinity values are all invalid. Many developers learn this the hard way after copying a JavaScript object literal into a JSON file. When the parser fails, this tool reports the line and column of the offending character — usually enough to find the problem instantly.

How to use the JSON Formatter

  1. Paste the JSON

    Drop the raw JSON into the input area. It can be minified, pretty-printed, or anywhere in between.

  2. Choose the format action

    Prettify with your choice of 2-space or 4-space indentation, or minify to remove all unnecessary whitespace.

  3. Inspect or copy

    The output appears below. If validation failed, the line and column of the error are highlighted so you can fix the source.

Worked examples

Example 1

Input: {"a":1,"b":[2,3]}

Result: {\n "a": 1,\n "b": [2, 3]\n}

Prettified with 2-space indentation.

Example 2

Input: {\n "a": 1,\n "b": 2\n}

Result: {"a":1,"b":2}

Same data minified for production use.

Example 3

Input: {'a': 1}

Result: Parse error at line 1, column 2

Single quotes are invalid in JSON — strings must use double quotes.

Real-world use cases

  • Reading a minified API response while debugging integration issues.
  • Pretty-printing a configuration file before committing it to version control.
  • Validating a JSON payload before sending it to an endpoint.
  • Minifying a static JSON asset to reduce bundle size.
  • Spotting structural mistakes in hand-written JSON (mismatched brackets, missing commas).

Tips & common mistakes

  • If the error message points to "unexpected end of input", you usually have an unclosed bracket or brace earlier in the document.
  • Trailing commas are the single most common source of "valid in JavaScript, invalid in JSON" errors. Watch for them after the last property of an object or last item of an array.
  • Comments are not valid JSON. If you need comments in configuration, switch to JSON5, JSONC, or YAML.
  • Property order is preserved in the output. JSON is technically unordered, but most parsers and most humans treat the printed order as meaningful.

Frequently asked questions

Is my JSON sent to a server?

No. Parsing, validation, and formatting all happen in your browser via JSON.parse and JSON.stringify. Nothing is uploaded.

What is the maximum size it can handle?

Modern browsers handle JSON documents up to tens of megabytes without trouble. Very large files (hundreds of megabytes) may freeze the page; in that case, stream-parse on the server instead.

Does it support JSON5 (with comments and trailing commas)?

No — only strict JSON. JSON5 requires a different parser. If you need to convert JSON5 to JSON, strip comments and trailing commas first, then format here.

Will it sort keys alphabetically?

Not by default. The original property order is preserved. Some teams prefer sorted output for stable diffs; that is best handled by a dedicated tool (jq, Prettier).

Related tools

Last updated: June 2026 · All processing happens locally in your browser.