Dzary Find a tool

JSON Formatter & Validator

Beautify or minify JSON and find the exact line of any error, without sending your data anywhere.

Status
Paste JSON and press Format.

Runs in your browser. Nothing you enter is uploaded or stored.

How to use the JSON formatter

  1. Paste JSON into the left box: an API response, a config file, a log line.
  2. Press Format (or Ctrl + Enter) to indent it, or Minify to strip all whitespace for production.
  3. If the JSON is invalid, the status box shows the line and column of the first problem, the reason in plain words, and a caret under the exact character.
  4. Tick Sort keys A–Z to make two objects easier to compare, then copy the output.

The data stays on your device, so it is safe to format responses that contain tokens or customer details. That said, it is good practice to remove secrets before pasting them into any web page.

What makes JSON valid

JSON is defined by RFC 8259. It is stricter than JavaScript object syntax, which is why code that works in a .js file often fails as JSON:

  • Keys and strings must use double quotes. Single quotes are not allowed.
  • No trailing comma after the last item in an object or array.
  • No comments of any kind.
  • Only six kinds of value: object, array, string, number, true/false and null. NaN, Infinity and undefined are not among them.
  • Numbers can't have leading zeros or a leading plus sign, and can't end in a dot.
  • Line breaks inside a string must be written as \n.

Common errors and how to fix them

InvalidProblemValid
{"a": 1,}Trailing comma{"a": 1}
{'a': 1}Single quotes{"a": 1}
{a: 1}Unquoted key{"a": 1}
{"a": 1 // id}Comment{"a": 1}
{"a": NaN}NaN, Infinity or undefined{"a": null}
{"zip": 007}Leading zero{"zip": "007"}
{"a": 1} {"b": 2}Two values at the top level[{"a": 1}, {"b": 2}]

Each of these produces a specific message in the status box, such as "Trailing comma before }", so you know what to change instead of hunting through a long file.

Worked example

The Sample button loads a one-line order record:

{"order":1042,"customer":{"name":"Ayesha Khan","email":"ayesha@example.com"},"items":[{"sku":"MUG-01","qty":2,"price":12.5},{"sku":"TEE-L","qty":1,"price":18}],"paid":true,"note":null,"id":12345678901234567890}

Formatted with two spaces, it becomes 22 readable lines with customer and each item in items on its own indented block. The status line reports 14 keys and a nesting depth of 3 (the root object, the items array and each item inside it).

Look at the last field, id. Its value, 12345678901234567890, is larger than JavaScript can store exactly (the safe limit is 9,007,199,254,740,991). Many online formatters run the text through JSON.parse and silently print 12345678901234567000. This formatter reads the original characters instead, so large IDs come out exactly as they went in, even when you sort the keys.

Duplicate keys and sorting

RFC 8259 says names within an object should be unique but does not forbid duplicates, and parsers disagree about what to do with them. Most, including browsers, keep the last value and drop the earlier ones without warning. The status line lists any duplicate keys it finds so you can decide which one you meant.

Sorting reorders keys by their raw text, so uppercase letters come before lowercase. Array order is never changed, because the order of an array is part of its meaning.

Accuracy and limits

Validation follows RFC 8259 strictly; JSON5, JSONC (JSON with comments) and JSON Lines are reported as invalid. Formatting keeps strings, escapes and numbers exactly as written. Files of a few megabytes format in well under a second on a typical laptop; very large files may be slow on older phones.

Frequently asked questions

Is my JSON uploaded to a server?

No. Parsing and formatting happen in your browser with JavaScript. Nothing is sent or stored, which also means the tool keeps working if your connection drops after the page has loaded.

Why does it say my JSON is invalid when it works in my code?

JavaScript objects allow single quotes, trailing commas, comments and unquoted keys, but JSON does not. Fix the item at the line and column shown and run it again.

What is the difference between formatting and minifying?

Formatting adds line breaks and indentation so people can read it. Minifying removes every unnecessary space and line break so the file is as small as possible for sending over a network. Both contain the same data.

Should I use 2 spaces, 4 spaces or tabs?

It makes no difference to the data. Two spaces is the most common choice for JSON in web projects, and many style guides use it. Pick whatever your project already uses.

Will it change large numbers or unicode escapes?

No. Numbers and strings are copied character for character, so an ID like 12345678901234567890 or an escape like \u00e9 stays exactly as you pasted it.