Skip to content
Menu
Theme

JSON Formatter and Validator

Format, minify, validate and sort JSON, or escape text for a JSON string. Keeps key order and big numbers as written. Free, and it runs in your browser.

DeveloperRuns in your browser
Paste or type here. The result updates as you type.

Valid JSON.

What is a JSON formatter?

A JSON formatter takes JSON that is hard to read and lays it out again with line breaks and indentation, so you can see which value belongs to which key. JSON from an API response, a log file or a config export often arrives as one long line. Reading that by eye is slow, and a missing bracket can hide anywhere.

This tool does five jobs on the same input. It can format JSON with two spaces, four spaces or tabs. It can minify it back to one compact line, which is handy before you paste it into a request or a small config field. It can sort the keys of every object from A to Z or from Z to A, either only at the top level or all the way down. And it can escape plain text so it fits inside a JSON string, or turn an escaped string back into plain text.

Every run also checks that the input is valid JSON. When something is wrong, you get the line and the column of the problem and a short reason, such as an unexpected character or a string that never closes. Comments and trailing commas are a common surprise here. Many code editors accept them, but they are not part of JSON, so the tool reports them as errors. If an object repeats the same key twice, the JSON is still valid, but the tool lists those keys so you can decide which value you meant.

The formatter keeps your data exactly as written. Keys stay in their original order, even keys that look like numbers, such as “2024”. Numbers keep their text too, so a long ID like 12345678901234567890 or a value like 1.0 comes out unchanged. Many online formatters quietly move number-like keys to the top and round big numbers, which can break an ID without any warning.

Everything runs in your browser. Your JSON is not sent anywhere, which matters when it holds access tokens, customer records or other data you should not paste into a stranger’s server.

How to use the JSON formatter

  1. Paste your JSON into the input box. It starts with a sample so you can see the result straight away.
  2. Choose what you want to do: format, minify, sort the keys, escape or unescape.
  3. For formatting and sorting, pick the indentation you like. For sorting, also pick the order and tick the box if nested objects should be sorted too.
  4. Read the output in the Result box. If the JSON has a problem, a message under the input shows the line and column to fix.
  5. Copy the result with the copy button and paste it where you need it.

FAQ

Why does it say my JSON is invalid when my editor accepts it?

Some editors and config tools accept extra things that JSON itself does not allow, such as comments, trailing commas, single quotes or keys without quotes. This tool follows the JSON standard strictly. Remove those parts and check the line and column it points to.

Will formatting change my numbers or the order of my keys?

No. The tool reads your text piece by piece instead of turning it into an object first, so the order of keys and the exact digits of each number stay as you wrote them. Only spacing and line breaks change.

What does sorting keys do with arrays?

Sorting changes the order of keys inside objects only. Items in an array keep their order, because in JSON the position of an array item usually carries meaning. If you tick the option for nested objects, objects inside arrays get their keys sorted too.

When do I need escape and unescape?

Use escape when you want to put a block of text, such as a message with quotes and line breaks, inside a JSON string. The tool adds the backslashes for you. Use unescape for the opposite case, when a log shows a string full of backslashes and you want to read the text behind it.

Is there a size limit?

The page handles JSON of up to two million characters. Very long results show only the first part on screen, but the copy button always copies the full text.

Is my JSON stored or sent anywhere?

No. All the work happens inside the page on your own device. Nothing is uploaded, and nothing is kept after you close the tab.

Related tools