JSON Formatter and Validator

Paste JSON to check it, then format it with clean indentation or minify it to a single line. The tool tells you right away if the JSON is valid, and points at the exact line and column when it is not. Everything runs in your browser, so your data stays on your device.

Paste or type JSON to check it
Indent
Result

What is JSON formatting?

JSON is a plain text format for storing and sending data, used by most APIs and config files. It is easy for machines to read, but a long string on one line is hard for a person to follow. Formatting rewrites that string with line breaks and indentation so the structure is clear, without changing any of the data. This tool formats your JSON, checks that it is valid, and can minify it back down to the smallest single-line version when you need it.

Why use our JSON formatter

  • ·Free. No signup, no paywall, no limits.
  • ·Runs in your browser. Your JSON is never uploaded, so it is safe for private data.
  • ·Live validation. See if your JSON is valid as you type, with the exact line and column of any error.
  • ·Format or minify. Pretty print for reading, or shrink to one line, in the same place.
  • ·Your choice of indent. Use 2 spaces, 4 spaces, or tabs, and sort keys when you want them in order.

JSON formatter options

Format

Rewrites your JSON with clean line breaks and indentation so nested objects and arrays are easy to read. Your data is not changed, only the spacing.

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

Minify

Strips every space and line break to give you the smallest valid JSON on a single line. Good for saving space in a request body or config value.

Before{ "a": 1, "b": 2 }After{"a":1,"b":2}

Indent

Choose 2 spaces, 4 spaces, or a tab for each level. Pick the one that matches your codebase so the result drops straight in without reformatting.

Before{"a":1}After{ "a": 1 }

Sort keys A to Z

Puts the keys of every object in alphabetical order, all the way down. Array order is left alone, since the position of items in a list has meaning.

Before{"name":"pear","age":2}After{ "age": 2, "name": "pear" }

Common JSON errors and how to fix them

JSON is stricter than JavaScript, so text that looks fine can still fail. These are the mistakes behind most errors, with the message Chrome shows for each:

ProblemExampleFix
Trailing comma after the last item{"a": 1,}Delete the last comma. Chrome says: “Expected double-quoted property name”.
Single quotes{'a': 1}Use double quotes for keys and text values.
Keys without quotes{a: 1}Put every key in double quotes: "a".
Missing comma between items{"a": 1 "b": 2}Add a comma. Chrome says: “Expected ',' or '}' after property value”.
Comments{"a": 1 // note}JSON has no comments. Remove them, or move the note into a value.
NaN, undefined, or Infinity{"a": NaN}Use null or a number instead.
Curly quotes from a doc or chat{“a”: 1}Replace the curly quotes with straight ones.

The error message gives a line and column. The real mistake is often just before that spot, since the parser only notices a problem when it reaches the next character it did not expect.

When to format JSON

JSON turns up all over modern development, and it is often packed onto one line. Here are the most common reasons people format and check it:

  • ·Reading an API response. Paste a minified response to see its structure and find the field you need.
  • ·Fixing a broken config file. Find the trailing comma or missing bracket that is stopping a file from loading.
  • ·Preparing a request body. Minify a formatted object down to one line to paste into a tool or script.
  • ·Comparing two objects. Sort the keys of both so the same fields line up and the real differences stand out.
  • ·Cleaning up before you commit. Format a data file with your project's indentation so it reads well in review.

Frequently asked questions

What is a JSON formatter?
A JSON formatter takes JSON that is on one line or has messy spacing and rewrites it with clean indentation and line breaks, so it is easy to read. It does not change the data, only the way it is laid out. This tool also checks that the JSON is valid and can minify it back down when you need the smallest version.
How do I format JSON?
Paste your JSON into the input box. The tool checks it as you type and shows a green Valid JSON message when it is correct. Pick your indentation, then click Format to see the clean version below. Click the copy button to copy it, or download it as a .json file.
How do I know if my JSON is valid?
The status bar under the input box updates live. If the JSON is valid, it shows a green check. If something is wrong, it shows the line and column of the problem along with the browser's own error message, so you can jump straight to the spot that needs fixing.
What does minify do?
Minify removes every space and line break and puts the whole JSON on one line. The result is the smallest valid version of the same data, which is useful when you want to paste it into a request body, an environment variable, or anywhere size matters.
Does sorting the keys change my data?
No. Sorting only reorders the keys inside each object into alphabetical order, which JSON treats as the same data. The values stay exactly as they were, and arrays keep their original order because the position of items in a list can be meaningful.
Why does it say my JSON is invalid?
The most common causes are a trailing comma after the last item, single quotes instead of double quotes, missing quotes around a key, or an unclosed bracket or brace. The error message points at the line and column where the parser gave up, which is usually at or just after the real mistake.
Is my JSON kept private?
Yes. All formatting, validating, and minifying runs in your browser. Your JSON is never uploaded to a server or saved anywhere, so you can safely paste in data that contains private values. Once the page has loaded you can even use it offline.