TechWeirdoTools

Input Empty

Output

Formatted JSON appears here.

How to format and validate JSON

  1. Paste or open your JSON

    Paste from an API response, log file or config — or open a .json file. Validation runs as you type.

  2. Fix any errors

    If the JSON is invalid, you’ll see the exact line and column with the surrounding text, plus a hint for common mistakes like trailing commas or single quotes.

  3. Format, minify or explore

    Pretty-print with 2 spaces, 4 spaces or tabs, minify to a single line, sort keys alphabetically, or switch to the tree view to collapse large objects.

Common JSON syntax errors

JSON (JavaScript Object Notation, RFC 8259) is stricter than JavaScript object literals. These mistakes cause most “Unexpected token” errors:

MistakeInvalidValid
Trailing comma[1, 2, 3,][1, 2, 3]
Single quotes{'a': 1}{"a": 1}
Unquoted keys{a: 1}{"a": 1}
Comments{"a": 1 // note}Remove comments
Special numbersNaN, Infinity, 0x1Fnull or a decimal number
Unescaped control charactersA raw tab or newline inside a string\t, \n

Format JSON on the command line

jq . data.json                      # pretty-print
jq -c . data.json                   # minify
python3 -m json.tool data.json      # pretty-print with Python
node -e "console.log(JSON.stringify(require('./data.json'), null, 2))"

Frequently asked questions

Is my JSON sent to a server?

No. Parsing, formatting and validation use your browser’s built-in JSON.parse and JSON.stringify. Your data never leaves the page, so it’s safe for API keys, tokens and private payloads.

How do I find where my JSON is invalid?

Paste it into the input. The validator reports the line and column of the first error and shows the surrounding text with a marker, so you can jump straight to the problem.

What is the difference between formatting and minifying?

Formatting (pretty-printing or beautifying) adds indentation and line breaks so humans can read it. Minifying removes all unnecessary whitespace to make the payload as small as possible for transfer or storage. Both represent exactly the same data.

Does sorting keys change my data?

No. JSON objects are unordered by specification, so sorting keys alphabetically doesn’t change meaning. It makes diffs and comparisons much easier. Array order is always preserved.

Can it handle large JSON files?

Yes. Files of several megabytes format in a fraction of a second. For very large documents, syntax colouring and the tree view are limited to keep the page responsive, but formatting, minifying and copying still work on the full data.