JSON Formatter & Validator

Format, validate, prettify, and parse raw JSON data.

How to Use JSON Formatter & Validator

  1. Paste your JSON into the input panel.
  2. Choose 2 or 4 spaces of indentation.
  3. Click Format to pretty-print it, Minify to strip all the whitespace, or Validate just to check it.
  4. Use Copy Result to copy the output.

Why your JSON is invalid

JSON is stricter than the JavaScript it came from. The same mistakes come up again and again: a trailing comma after the last item in an object or array, single quotes instead of double quotes, keys without quotes, comments (JSON doesn't allow any), and values like undefined, NaN or Infinity. Text copied from a log file can also bring invisible characters along, or lose a closing bracket.

When the JSON can't be parsed, the tool shows your browser's own error message, which normally gives the position where parsing stopped, and in some browsers the line and column too. The real mistake is usually just before that point.

Formatting doesn't change your data

Pretty-printing and minifying only change whitespace. Keys and values stay the same, and so does their order, with one exception: keys that look like whole numbers are always put first, in numeric order, because that's how JavaScript objects work.

Two other things to know. Duplicate keys in one object collapse to the last value. And whole numbers larger than about 9 quadrillion (2^53), which some databases use for IDs, can lose precision because JavaScript stores every number as a 64-bit float. If you deal with very large numeric IDs, keep them as strings.

2 spaces or 4?

It's purely a style choice. Two spaces is the norm in most JavaScript projects and keeps deeply nested data from drifting off the right edge; four is common in Python and Java codebases. Minified JSON is what you'd send over the network or store, since every unnecessary byte of whitespace is gone.

Key Features & Practical Use Cases

  • Making an API response or webhook payload readable while debugging.
  • Finding the exact spot where a config file or package.json is broken.
  • Minifying JSON before putting it in an environment variable, URL or database field.
  • Tidying test fixtures so diffs are easier to read in code review.

Frequently Asked Questions

Is my JSON sent to a server?

No. It's parsed with your browser's built-in JSON.parse, so any API keys or customer data in it stay on your machine.

Can it fix invalid JSON for me?

No. It shows where parsing failed so you can fix it. Automatic fixing means guessing what you meant, which can quietly change your data.

Does it support JSON with comments or JSON5?

No, only standard JSON. Remove comments, trailing commas and single quotes first.

How large a file can it handle?

A few megabytes is fine on a normal computer. Very large files, tens of megabytes, can make the page sluggish because everything happens inside the browser tab.

About OneClickly

OneClickly is a set of 119 free tools for PDFs, images, text, everyday math and code. They run in your browser, so the files and text you work with stay on your device.

Related Tools

  • JSON to CSV Converter - Convert a JSON array into CSV you can open in Excel or Google Sheets.
  • CSV to JSON Converter - Turn CSV or spreadsheet data into a JSON array, with quoted fields handled properly.
  • HTML Formatter - Indent messy HTML so it is easy to read, or minify it to a single line.
  • SQL Formatter - Format and beautify SQL queries across multiple database dialects.
  • CSS Minifier - Remove comments and spaces from CSS to make the file smaller.
  • JavaScript Minifier - Minify JavaScript with terser: removes whitespace and comments and shortens local names.