Skip to content
MoneyDeck

JSON Formatter & Validator

Beautify, minify and validate JSON with the exact line and column of any error

Updated · Free, no signup

Formatted JSON

{
  "name": "Ada",
  "age": 36,
  "skills": [
    "math",
    "engines"
  ],
  "address": {
    "city": "London",
    "zip": null
  }
}

Validation

Valid JSON

Error details

None

Error line

0

Error column

0

Total keys

6

Nesting depth

2

Output size

135 characters

Output lines

12

About the JSON Formatter & Validator

This JSON formatter and validator cleans up JSON in one paste. Choose Pretty print to indent it with 2 spaces, 4 spaces or tabs so nested objects are easy to read, or Minify to strip every unnecessary space for the smallest payload. Optionally sort object keys alphabetically at every level, which makes two JSON documents far easier to compare in a diff.

When the input is not valid JSON, the validator reports what went wrong and the exact line and column — trailing commas, single-quoted strings, unquoted keys, missing brackets and raw line breaks inside strings are all called out specifically. It also counts keys, measures nesting depth and warns when integers exceed JavaScript's safe range and would lose precision.

It is designed for developers debugging API responses, editing config files, or preparing request bodies. Parsing happens entirely in your browser, so tokens, customer records and other sensitive payloads never leave your device.

How to use the json formatter & validator

  1. 1Paste your JSON into the input box.
  2. 2Choose Pretty print or Minify, and the indentation you prefer.
  3. 3Turn on key sorting if you want a stable, diff-friendly order.
  4. 4If the status says Invalid JSON, go to the reported line and column and fix the issue.
  5. 5Copy the formatted result with the copy button.

Formula and method

The input is first checked by a strict validator that follows the JSON grammar in RFC 8259: objects use double-quoted keys, strings use double quotes with valid escapes, numbers have no leading zeros or trailing dots, and only true, false and null are allowed as literals. Trailing commas, comments and single quotes are rejected. When a rule is broken, the character offset is converted into a 1-based line and column so you can jump straight to the problem.

Valid input is parsed and re-serialised. Pretty print inserts line breaks and the chosen indentation for every nested level; minify removes all insignificant whitespace. With key sorting on, object keys are ordered alphabetically at every depth while array order is preserved. Key count includes keys in nested objects, and depth counts levels of nested objects/arrays.

Worked examples

Pretty-print a minified object

The one-line sample has 4 top-level keys plus 2 inside "address", so 6 keys in total, nested 2 levels deep. Indented with 2 spaces it becomes 12 lines and 135 characters.

Minify for an API request

Sorting puts "a" before "b" and "c" before "d" (array order is untouched), and minifying removes every space and newline, giving a 32-character single line. There are 4 keys across 3 levels of nesting.

Find a trailing comma

JSON does not allow a comma after the last array item. The validator stops at the closing bracket on line 3, column 21 and explains that a trailing comma precedes it — delete the comma after "b" to fix it.

Frequently asked questions

Why is my JSON invalid when it works in JavaScript?+

JavaScript object literals allow single quotes, unquoted keys, trailing commas and comments, but JSON allows none of these. Convert keys and strings to double quotes and remove trailing commas and comments.

Does JSON allow comments?+

No. The JSON standard (RFC 8259) has no comment syntax. Some tools accept JSONC or JSON5, which do, but standard parsers such as JSON.parse and most APIs will reject a file containing // or /* */ comments.

What is the difference between pretty print and minify?+

Pretty print adds line breaks and indentation so humans can read the structure. Minify removes all optional whitespace to make the payload as small as possible for storage or network transfer. The data itself is identical.

Why do large numbers change after formatting?+

JavaScript stores numbers as 64-bit floats, which represent integers exactly only up to 9,007,199,254,740,991. Larger IDs (common in Twitter/X or database APIs) get rounded, so send them as strings instead.

Is my JSON uploaded anywhere?+

No. Validation and formatting run entirely in your browser with JavaScript. Nothing you paste is sent to MoneyDeck or any other server, so it is safe to use with private data.

Related tools