🧩 JSON Formatter & Converter

Format, validate and minify JSON, or convert JavaScript objects to JSON.

Ad space (paste AdSense unit here)

Free JSON formatter, validator and converter

Paste JSON and this tool will beautify it with clean indentation, minify it to save space, or tell you exactly where a syntax error is. It also does something many formatters do not: if you paste a JavaScript object or array, such as the data from a config file, it converts it to valid JSON and lets you download it as a .json file. Everything runs in your browser, so your data is never uploaded.

How to use it

  1. Paste your JSON, JavaScript object or array into the input box, or upload a file.
  2. Choose 2 spaces, 4 spaces or a tab for indentation.
  3. Click Format / Convert to JSON to beautify it, or Minify to compress it onto one line.
  4. Copy the result, or enter a file name and click Download .json.

Press Ctrl+Enter inside the input box as a shortcut for Format.

What gets fixed automatically

When your input is not strict JSON, the tool tries to read it as a JavaScript object or Python dictionary and clean it up:

  • Single quotes become double quotes, and unquoted keys get quotes.
  • Trailing commas are removed.
  • Comments written with double slashes, slash-star blocks or a hash sign are stripped out.
  • The values undefined, NaN and Infinity become null, because JSON cannot store them.
  • Python values True, False and None become true, false and null.
  • Hexadecimal numbers such as 0xFF become ordinary decimal numbers.
  • Wrappers such as export const items = or module.exports = are removed so only the data remains.

Common JSON errors

  • Missing or extra comma: every item except the last needs a comma after it.
  • Single quotes: strict JSON only allows double quotes around text and keys.
  • Unclosed bracket or quote: every opening bracket and quote needs a matching closing one.
  • Comments: strict JSON does not allow comments.

When something cannot be converted, the tool shows the line and column of the problem and marks the spot with a pointer.

Can I convert a whole program to JSON?

No. JSON can only store data: objects, arrays, text, numbers, true, false and null. Functions and program logic cannot be turned into data. If you only need the code saved inside a JSON file, use Wrap code as JSON, which stores your code as text in an object, an array of lines or a single string. The code is never run.

Limits and privacy

Input is limited to 5 million characters, uploaded files to 2 MB, and data nested more than 200 levels deep is rejected to keep your browser responsive. Pasted code is parsed as text and never executed. Nothing is sent to a server.

Frequently asked questions

What is the difference between formatting and minifying?

Formatting adds line breaks and indentation so people can read it. Minifying removes all unnecessary spaces so the file is as small as possible.

Does formatting change my data?

No. Only whitespace changes. The values stay the same. When the input needed conversion, the message tells you which kinds of changes were made.

Why did my undefined value turn into null?

JSON has no undefined value, so null is the closest standard replacement.

Can it handle large files?

Up to the limits above. Extremely large files are better handled with a desktop tool.

More free tools