JSON

JSON Formatter with Parse Error Positions

Format, validate, and beautify JSON with syntax highlighting

100% client-side — your data never leaves your browserNo data stored or uploadedFree for lifetime · No signup
Formatted output will appear here
■ key■ string■ number■ boolean■ null

What is a JSON formatter?

A JSON formatter takes raw JSON — often a single unreadable line copied from an API response, a log file, or a database record — and pretty-prints it with consistent indentation so the structure becomes visible at a glance. This tool also validates as it formats: if the input isn't legal JSON, you get the exact parser error instead of silently broken output.

Everything runs in your browser. The JSON you paste is never uploaded, stored, or logged, which makes it safe to format payloads that contain internal identifiers or customer data.

When to use it

Reach for a formatter whenever you're debugging an API response and need to find one field inside a wall of minified JSON, when you're writing configuration by hand and want to confirm it parses before deploying, or when a teammate sends you a payload and you need to talk about a specific nested value. The Minify option does the reverse — strips all whitespace — which is useful before embedding JSON in a URL, an environment variable, or a size-sensitive request body.

The validator is also the fastest way to hunt down the classic JSON mistakes: trailing commas, single quotes instead of double quotes, unquoted keys, and comments (JSON allows none of these). The error message points at the position where parsing failed, so you can fix it instead of guessing.

Example

Paste {"user":{"id":42,"name":"Ada","roles":["admin","dev"]}} and Format produces an indented tree where each key sits on its own line — with keys, strings, numbers, booleans and nulls color-coded. Switch the indent between 2 and 4 spaces to match your codebase's style, then copy the result or share it with the "Copy link to this result" button, which encodes your input into the link itself.

Pretty print JSON from the command line and in code

When the JSON is already in a terminal or a script, you don't need a web page. Python ships a formatter: python -m json.tool data.json prints it with a 4-space indent (add --indent 2 for two), and cat data.json | python -m json.tool works on piped input. jq is the standard for anything bigger: jq . data.json pretty-prints with colour, and jq -c . minifies.

In JavaScript, JSON.stringify(obj, null, 2) produces exactly what the Format button here does — this page runs JSON.parse followed by JSON.stringify with your chosen indent — and JSON.stringify(obj) is the Minify equivalent. In Python code, json.dumps(obj, indent=2, ensure_ascii=False) keeps non-ASCII characters readable instead of escaping them to \u sequences.

This page earns its place when the JSON came from somewhere else — a log line, the browser's network tab, a chat message — and you want it validated and readable without saving a file first, or when you need to send someone a link that opens the same input, ready to format.

Common JSON errors and how to fix them

Nearly every parse failure is a habit carried over from JavaScript or Python.

Trailing commas: {"a": 1,} and [1, 2,] are legal in JavaScript but not in JSON — delete the comma before the closing brace or bracket. Single quotes: {'a': 'b'} is what Python prints for a dict, and it is not JSON; produce real JSON with json.dumps() or switch to double quotes. Comments: // and /* */ are not part of JSON. tsconfig.json and VS Code settings accept them because those tools use a lenient JSONC parser; strict parsers, including this page, reject them. Unquoted keys: {a: 1} must be {"a": 1}. Python literals: True, False and None must be true, false and null. Special numbers: NaN and Infinity have no JSON form — use null or a string.

The error text comes from your browser's own JSON parser, so the wording differs between Chrome, Firefox and Safari, but each reports where parsing stopped. Look at that position and just before it: the real mistake is often the character immediately preceding, such as the comma before a closing brace or a missing quote that opened a string too early.

Using it as a JSON validator, checker or linter

To validate JSON online without changing it, paste it and press Validate. The page runs your browser's strict JSON.parse on the text: if it parses, you get a green valid message and nothing else happens; if not, you get the parser's error with the position where it stopped. That is the same strict RFC 8259 grammar used by fetch().json(), Node.js and most API servers, so passing here means a standards-compliant parser will accept the document.

What it checks is syntax, which is what most people mean by a JSON checker: matching braces and brackets, double-quoted keys and strings, commas between items but not after the last one, valid escapes, and only true, false, null, numbers, strings, arrays and objects as values. It does not validate against a JSON Schema, so it cannot tell you that a required field is missing or that an id should be a number; use a schema validator such as Ajv for that. A JSON linter in an editor or CI pipeline usually adds style rules such as key order or indentation; the closest equivalent here is running Format with your chosen indent and comparing the result with your file. Duplicate keys are not reported as errors because JSON.parse accepts them, keeping the last value.

How to use the JSON Formatter with Parse Error Positions tool

  1. 1

    Paste your JSON

    Drop raw or minified JSON into the input panel on the left.

  2. 2

    Choose an action

    Format pretty-prints with your chosen indent, Minify strips whitespace, Validate just checks syntax.

  3. 3

    Fix any errors

    If parsing fails, the error message shows what went wrong and where.

  4. 4

    Copy or share

    Copy the output, or copy a permalink that restores your exact input for anyone who opens it.

Frequently asked questions

Is my JSON uploaded to a server?

No. Formatting, validation and minification run entirely in your browser with JavaScript's built-in JSON parser. Nothing you paste leaves your machine.

Why does my JSON fail to validate?

The most common causes are trailing commas, single quotes instead of double quotes, unquoted property names, comments, or NaN/Infinity values — none of which are allowed in strict JSON. The error message shows the position where the parser stopped.

What's the difference between Format and Validate?

Validate only checks whether the input parses and reports errors. Format additionally pretty-prints the parsed result with your chosen indentation and syntax highlighting.

Is there a size limit?

Only your browser's memory. Because processing is local, even multi-megabyte payloads format quickly — nothing is sent over the network.

What's the difference between a JSON formatter, beautifier and validator?

Formatter and beautifier are two names for the same thing: re-indenting JSON so its structure is readable. A validator only checks that the text parses as strict JSON. This page does both — Validate checks syntax without changing anything, Format validates and pretty-prints in one step.

Is there a JSON formatter Chrome extension, and do I need one?

This is a web page, not an extension. A viewer extension pays off if you open raw JSON URLs in the browser all day, since it formats API responses in place — but it typically asks for permission to read every site you visit. This page needs no install or permissions, and suits JSON copied from logs, terminals or chat, checking a config before you commit it, or sharing a formatted result by link. Firefox has a built-in JSON viewer that covers the raw-URL case with no extension at all.

Can formatting change my numbers?

It can, in two ways that come from JavaScript's JSON parser. Integers beyond 9007199254740991 (2^53 − 1), such as 64-bit database IDs, lose precision and come back rounded. And numeric notation is normalised: 1.0 becomes 1 and 1e3 becomes 1000. If exact large integers matter, keep them as strings in the JSON, or format with jq 1.7+, which preserves the original number literals.

Does it keep my key order and duplicate keys?

Key order is kept, with one JavaScript quirk: keys that look like non-negative integers ("1", "42") are moved to the front in ascending order. Duplicate keys are not an error in JSON.parse — the last value silently wins and the earlier ones disappear from the output, so formatting is a quick way to spot a duplicate you didn't intend.

Can I use this as a JSON validator without reformatting my file?

Yes. Validate only checks the syntax with JSON.parse and reports either a valid result or the exact parse error and position. Your input is left as it is; only Format and Minify produce new output.

Does the JSON checker validate against a JSON Schema?

No. It checks that the text is syntactically valid JSON under the strict standard grammar. Checking required fields, types or allowed values needs a JSON Schema validator such as Ajv, or a schema configured in your editor.

Related on TechLogHub

Get the next tool before you need it

One email a week: new and trending developer tools, fresh comparisons, and what shipped. Unsubscribe in one click.