100 free tools for text, SEO, developers, DNS and imagesEvery tool runs locally in your browser. No sign-up. Nothing is uploaded.

JSON Formatter and Validator

JSON formatter and validator: format, minify and validate JSON with exact line and column errors and a tree view. Free, no sign-up, and it runs in your browser.

Dedicated page: /en/json-formatter

Quick answer

A JSON formatter and validator takes raw or minified JSON and makes it readable with proper indentation, while checking it is valid. If the JSON is broken, it reports the exact line and column of the error, and a collapsible tree view lets you explore large nested objects and arrays.

About this JSON Formatter and Validator

JSON formatter and validator: format, minify and validate JSON with exact line and column errors and a tree view. It is one of the Developer Tools on ToolUstad, and like every tool here it runs entirely in your browser: nothing you type, paste or open is uploaded to a server, and there is no sign-up or usage limit.

What is JSON formatting and validation?

JSON, JavaScript Object Notation, is the data format APIs use to talk to each other. Servers usually send it minified, as one unreadable line, and a single missing comma or bracket makes it invalid. Formatting, also called pretty printing or beautifying, rewrites the JSON with line breaks and consistent indentation. Validation parses the text against the JSON specification and, when it fails, pinpoints where the structure broke.

What this formatter does

  • Formats with your choice of 2 spaces, 4 spaces or tabs.
  • Validates and reports errors with line and column numbers, not just "invalid".
  • Minifies valid JSON back to one line for production payloads.
  • Tree view renders the data as collapsible nodes so you can inspect deep nesting.
  • Sorts keys alphabetically when you need to compare two payloads.

When and why developers format JSON

  • Debugging API responses: find the one wrong field in a 5,000 line response body.
  • Reading config files: package.json, tsconfig and countless settings files are JSON or close to it.
  • Cleaning data before import: validate exports from one system before feeding them to another.
  • Learning and documentation: show example payloads in a readable shape in docs and tickets.

Best practices

  • Validate before you format: formatting invalid JSON only makes the error prettier.
  • Diff sorted keys output when comparing two API responses for changes.
  • Keep production payloads minified, and format only your local working copy.

Common mistakes to avoid

  • Trailing commas after the last item: legal in JavaScript, illegal in JSON.
  • Single quotes around keys or strings: JSON requires double quotes.
  • Unescaped control characters and comments inside the data.
  • Pasting JSON with keys like undefined or NaN, which are not valid JSON values.

Who is the JSON formatter for?

Front end and back end developers, QA engineers, data analysts cleaning exports, and support staff reading API logs. Doing this in a code editor works, but it means opening the editor, pasting into a scratch file and trusting a plugin, while the formatter gives the answer, and the error location, in the tab you already have open. Nothing is uploaded, which matters when payloads contain tokens or customer data.

Reading error messages like a debugger

When validation fails, the line and column in the error are where the parser gave up, which is usually a few characters after the real mistake. Work backwards from that point: check the last comma, quote and bracket before it. Nine times out of ten it is one of the classics: a missing comma between two fields, a trailing comma, or a string that contains an unescaped quote or newline. The tree view helps on valid but confusing payloads too: collapse the top level, expand one branch at a time, and the structure of a nested API response becomes obvious in seconds.

Learn: how to use the JSON Formatter and Validator

  1. Paste your JSON into the input box. Broken JSON is fine: that is what the validator is for.
  2. Click Format for pretty JSON, Minify for a single line, or Validate only to check without changing anything.
  3. If there is an error, the message tells you the line and column to fix. Correct it and format again.
  4. Switch to Tree view to expand and collapse nested objects and arrays, then copy or download the result.

Features

  • Format with 2 spaces, 4 spaces or tabs
  • Validation errors with exact line and column, plus the likely cause
  • One-click minify with before and after sizes
  • Collapsible tree view with key and item counts and colour-coded values
  • Sample JSON button so you can test instantly
  • Copy and download as a .json file

Worked example

Input: {"a":1,"b":[1,2,3]} with a trailing comma added ({"a":1,}) reports an error at the exact position of the bad comma, the single most common JSON mistake.

Frequently asked questions

Why does JSON.parse reject my file?

The usual causes are trailing commas, single quotes instead of double quotes, unquoted keys, comments, or a missing comma between items. The error line and column point at the spot.

What is the difference between format and validate?

Validate only checks correctness and changes nothing. Format rewrites valid JSON with consistent indentation so it is easy to read and diff.

Is my JSON sent to a server to be checked?

No. Parsing uses the JSON parser built into your browser. Nothing leaves your device.

Can it handle large JSON files?

Yes, paste multi-megabyte JSON if your device can hold it in the page. Very large pastes may type slowly in the input box, but formatting still works.

Is my JSON uploaded to a server?

No. Formatting and validation run with JavaScript in your browser using the standard JSON parser. That makes this tool safe for payloads that contain API keys, session tokens or personal data, though you should still treat secrets carefully.

What is the difference between formatting and validating?

Validation checks whether the text follows the JSON rules at all. Formatting assumes valid JSON and rewrites it with indentation for readability. This tool does both: it validates first and formats only when the JSON parses.

Why does JSON reject trailing commas and single quotes?

Because the JSON specification is deliberately stricter than JavaScript object syntax. Keys must be double quoted strings, and commas may only separate items, never end a list. Those two rules cause most real world JSON errors.

Related tools

More Developer Tools like this one, plus two picks from other categories. Each opens its own dedicated page.

See all 100 tools
Copied