Skip to content

JSON formatter: format and validate JSON online

Paste JSON to pretty print it with 2, 3 or 4 spaces or tabs, squeeze it onto one line, or sort every key from A to Z. If something is wrong, the validator tells you what and where, by line and column, and jumps to the spot. The JSON never leaves your browser, so API keys and customer records stay on your device.

Quick answer

To format JSON, paste it into the left box: valid JSON appears pretty printed on the right, ready to copy or download as a .json file. Choose Minify to remove all spacing. If it is invalid, you see the line and column of the first problem with a plain reason, such as a trailing comma or single quotes.

Based on RFC 8259, The JSON Data Interchange Format (IETF) · Page updated 18 October 2026

Formatted on your device. Nothing is uploaded or saved.

How to use the JSON Formatter & Validator

  1. Paste your JSON into the first box, open a .json file, or press Sample to try it.
  2. Pick Pretty print with an indent of 2, 3 or 4 spaces or a tab, or pick Minify. Tick Sort keys to order every object's keys alphabetically.
  3. If a red box appears, read the line and column, press Go to error and fix the text. When it says Valid JSON, copy the result or download it as a .json file.

What the validator checks

The tool reads your text against the JSON grammar in RFC 8259, the IETF standard for JSON. Keys and strings must use double quotes; the only literals are true, false and null; numbers cannot have leading zeros or a trailing point; and there are no comments and no comma before a closing bracket. Each of these is a common copy-and-paste slip, so the error message names it in plain words, for example "Trailing comma before ]" or "Single quotes are not allowed", rather than a bare "Unexpected token".

Line and column, counted as you see them

The position of an error is counted in characters as they appear on screen, starting at line 1, column 1. Arabic text, accented letters and emoji count as one character each, so the column matches what your editor shows. Press Go to error and the cursor lands on the exact character, even in a file of several thousand lines.

Big numbers and duplicate keys

Most online formatters run JSON through the browser's own parser, which stores numbers as 64-bit floating point. RFC 8259 notes that only integers between −(2^53 − 1) and 2^53 − 1 are exchanged exactly that way, so a 19-digit order ID can come back changed in its last digits. This formatter keeps every number exactly as written and warns you when a value is beyond that range, because other programs may round it. The standard also says object keys should be unique; if a key appears twice, the tool keeps both and lists them, rather than quietly keeping only the last one.

Sorting keys and minifying

Sort keys orders the keys of every object by Unicode code point, the same order common command-line tools use, so two files with the same data but a different key order become easy to compare. Arrays keep their order, because order in an array carries meaning. Minify removes every space and line break outside strings, which gives the smallest file for an API request or a config value; text inside quotes is never touched.

Encoding, Arabic text and the escape option

RFC 8259 requires JSON exchanged between systems to be UTF-8, and Arabic or any other script can be written directly inside strings. If a system you send JSON to only accepts ASCII, tick Escape non-ASCII and every such character is written as a \u escape instead. A byte order mark at the start of a file is accepted and reported, since the standard says senders must not add one.

Frequently asked questions

Is this JSON formatter safe for API keys and private data?

Yes. Formatting and validation run in JavaScript in your browser. The text is not uploaded, logged or saved, so you can close the tab and nothing remains.

Why does my JSON fail with a trailing comma?

JSON does not allow a comma after the last item of an object or array, even though JavaScript does. Remove the comma before the closing } or ] and the error goes away.

Can it fix single quotes and comments automatically?

No. It shows where they are so you can decide, because changing quotes or deleting comments could change the meaning. Standard JSON needs double quotes and has no comments.

Does sorting keys change my data?

Only the order of keys inside objects changes. Values, arrays and their order stay the same, and programs that read JSON treat the sorted and unsorted versions as the same data.

How large a JSON file can I format here?

Files of several megabytes work on a normal computer. Very large files, tens of megabytes, may take a few seconds on a phone, because everything is processed on your own device.