Skip to content
DeveloperRuns in your browserPopular

JSON Formatter & Validator

Pretty-print JSON with your chosen indent and see exactly where errors are.

Input
No upload needed — instant
Privacy
Nothing is uploaded
Cost
Free · no sign-up · no watermark

Loading tool…

The tool is loading its code on your device. This happens once and is cached for later visits.

Processed entirely on your device

Everything you type or paste is handled by JavaScript running in this tab. No request is sent, nothing is logged and nothing is stored. Close the page and it is gone.

Overview

About the JSON Formatter & Validator

Format, validate and beautify JSON online. Precise error positions, 2 or 4 space or tab indentation, key sorting and a collapsible tree view — all client-side.

JSON is simple enough that everyone thinks they can eyeball it, and large enough that nobody actually can. A formatter is the difference between finding a missing comma in two seconds and finding it in ten minutes.

What "valid JSON" actually requires

The specification is small and unforgiving:

  • Strings must use double quotes. Single quotes are invalid.
  • Object keys must be quoted strings. Unquoted keys are JavaScript, not JSON.
  • No trailing commas. [1, 2, 3,] and {"a": 1,} both fail.
  • No comments. // and /* */ are not part of JSON — JSONC and JSON5 add them, and many config parsers accept them, but a strict parser will not.
  • Only six value types: object, array, string, number, true, false, null. Not undefined, not NaN, not Infinity, not dates.
  • Numbers cannot have a leading plus, cannot be hexadecimal, and cannot have a leading zero before a digit sequence.

Most "why is my JSON broken" questions are answered by that list.

Reading the error output

A native parse failure reports a character position, which is useful but not directly navigable. This tool converts that offset into a line and column number and shows the surrounding text with a caret under the offending character. When the reported position is the end of the document, the real problem is almost always an unclosed bracket earlier — count your braces.

Indentation choices

Two spaces is the prevailing convention in JavaScript and Node ecosystems and what JSON.stringify(value, null, 2) produces.

Four spaces is common in Python and Java shops and easier to read in deeply nested documents.

Tabs keep indentation width a viewer preference rather than a file property.

Whatever you choose, be consistent — mixed tabs and spaces are invisible in most editors and maddening in diffs.

Sorting keys for diffing

Alphabetically sorted keys turn a structural comparison into a line comparison. Two versions of the same config diff cleanly line by line instead of showing a whole object as changed because a member moved. This is why canonical JSON representations used in signing schemes specify a key order.

Big integers

JSON has no integer type distinct from number, and JavaScript numbers are IEEE-754 doubles. Any integer above 2^53 − 1 (9007199254740991) loses precision on parse. Database IDs and snowflake identifiers routinely exceed that. The large-integer option rewrites long numeric literals as strings before parsing so they survive formatting intact — but remember that the resulting document is no longer the same JSON, so use it for inspection rather than for round-tripping.

Step by step

How to use the JSON Formatter & Validator

  1. Paste your JSON into the input panel, or drop a .json file onto it.

  2. Press Format — valid JSON is pretty-printed instantly.

  3. If it is invalid, read the error message: it names the character position and the line.

  4. Choose indentation, toggle key sorting, or switch to the tree view.

  5. Copy the formatted output or download it as a .json file.

Why use it

Benefits and common use cases

What this tool is good for, and what it deliberately does not try to do.

Errors with a position, not just a message

Reports the exact character offset, line and column, plus a snippet of the surrounding text — so you find the missing comma rather than scanning the whole document.

Validates as it formats

Formatting is impossible without parsing, so a successful format is proof the JSON is syntactically valid. No separate validation step needed.

Tree view for large payloads

Collapse and expand nested objects and arrays to navigate a deep API response without scrolling through thousands of lines.

API responses stay on your machine

Payloads frequently contain tokens, user records and internal endpoints. Parsing happens in your tab, so nothing is posted anywhere.

Questions

Frequently asked questions

Short, honest answers about quality, limits and privacy.

Why is my JSON invalid when it looks correct?

The usual culprits: a trailing comma after the last item in an object or array, single quotes instead of double quotes, unquoted keys, JavaScript-style comments, the values undefined or NaN, or smart quotes pasted from a document or chat app.

Does this handle JSON with comments (JSONC)?

The strict parser rejects comments because they are not valid JSON. A toggle strips // and /* */ comments before parsing so JSONC files — tsconfig.json, .vscode settings, eslint configs — can still be formatted and inspected.

What does sorting keys do, and is it safe?

It reorders object members alphabetically, which makes two versions of a document easy to diff. It is safe for data but not for formats where key order is significant, such as JSON-LD in some processors or signature canonicalisation schemes.

Is there a size limit on the JSON I can format?

No imposed limit. The constraint is browser memory and parsing time — documents beyond a few megabytes will still work but the tree view may become sluggish. Very large payloads are better handled with jq on the command line.

Are numbers or precision changed by formatting?

The tool parses with the native JSON parser, so numbers beyond 2^53 lose precision exactly as they would in any JavaScript environment. A large-integer preservation option keeps long numeric literals as strings so IDs from databases survive intact.