HassleFreeTools

JSON Formatter and Validator

Format, minify and validate JSON in your browser. Errors are shown with the exact line and column, and numbers are kept exactly as written.

Paste JSON to check it as you type.

Input
–
Result
–
Lines
–

Runs entirely in your browser. Your files and text are not uploaded.

How to use JSON Formatter and Validator

  1. Step 1: Add your JSON

    Paste or type JSON into the input box, or open or drop a .json file of up to 20 MB.

  2. Step 2: Format or minify

    Choose 2 spaces, 4 spaces or tabs, switch on key sorting if you want it, then press Format or Minify.

  3. Step 3: Fix errors or save

    If the JSON is invalid, the tool shows the line and column and selects the problem in the input. Otherwise copy the result or download it.

What the formatter changes

Formatting only changes the whitespace between values: line breaks and indentation for Format, and none at all for Minify. Everything else is copied exactly as you wrote it:

  • Numbers keep their original digits. 1.50 stays 1.50, 1e3 stays 1e3, and a 19-digit ID is not rounded.
  • Strings keep their escape sequences, so \u00e9 is not turned into é and nothing is re-encoded.
  • Key order stays the same unless you switch on Sort keys A to Z. Sorting is recursive, so keys inside nested objects are sorted too, but the order of items in an array never changes. Keys are compared by character code, as jq does, so capital letters come before lower-case ones.

How validation works

The tool checks your JSON against the standard (RFC 8259) as you type and reports the first problem with its line and column. When you press Format, it selects the faulty character in the input and shows an excerpt with a marker under it. The checking is done by the tool itself rather than by the browser, so the message and the position are the same in Chrome, Firefox and Safari.

These are the mistakes it explains most often:

  • a trailing comma before } or ], or a missing comma between two values
  • single quotes or curly quotes instead of straight double quotes
  • property names without quotes, as written in JavaScript code
  • comments, NaN, undefined, and Python's True, False and None
  • numbers with leading zeros, such as 0123
  • brackets or strings that are never closed, and line breaks inside strings
  • invisible characters, such as non-breaking spaces copied from a web page

It also warns about two things that are valid but risky: the same key repeated inside one object (most programs keep only the last value) and whole numbers larger than 9,007,199,254,740,991.

Large numbers and precision

JavaScript stores numbers as 64-bit floating point values, which hold whole numbers exactly only up to 2^53 − 1 (9,007,199,254,740,991). Formatters that parse the JSON and write it out again silently change a value such as 12345678901234567890 into 12345678901234567000. This formatter copies the digits instead. The program that later reads your JSON may still round them, so store such IDs as strings when the exact value matters.

Privacy

Your JSON is processed by JavaScript on your own device. It is not uploaded, logged or stored, so you can use the tool for API responses and configuration files that contain private data. Large inputs are handled in a background thread of your browser to keep the page responsive.

Limitations

  • Files can be up to 20 MB. Inputs over about 1 MB are not shown in the editor and are checked when you press Format or Minify. The result box then shows the first 1,000,000 characters; Copy and Download always include the full result.
  • Only standard JSON is accepted. JSON5, JSON with comments (JSONC) and JSON Lines files are reported as errors, not converted.
  • Only the first error is reported. Fix it and the next one, if there is one, appears.
  • Whole numbers larger than 9,007,199,254,740,991 (2^53 − 1) are kept exactly here, but JavaScript's own JSON parser and many other programs round them when they read the file.
  • Sorting compares keys character by character, so “Zebra” comes before “apple” and “item10” comes before “item2”.
  • Repeated keys are kept as they are. The tool warns about them but does not merge or remove them.
  • Very large files can be slow on phones, because the whole file is held in the browser's memory.

Frequently asked questions

Is my JSON uploaded anywhere?

No. Formatting and validation run in your browser. The JSON is not sent to our server or stored, and it is cleared when you close the page.

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

JavaScript object literals allow things that JSON does not: single quotes, property names without quotes, trailing commas, comments and values such as undefined. JSON needs double quotes around every name and string, and nothing else. The error message tells you which of these it found and where.

Will formatting change my numbers or text?

No. Only spaces, tabs and line breaks between values change. Numbers keep their exact digits and strings keep their escape sequences. With key sorting on, the order of keys changes as well, but no values do.

What is the difference between Format and Minify?

Format adds line breaks and indentation so people can read the JSON. Minify removes every optional space and line break to make the smallest file, which is useful for sending data over a network. Both contain exactly the same data.

Can I format a JSON Lines (.jsonl) file?

Not directly. JSON Lines puts one JSON value on each line, which is not a single valid JSON document. Put the lines inside [ ] and separate them with commas to turn them into one array, then format that.

Does sorting keys change the order of array items?

No. Only the keys inside objects are sorted, at every level. Arrays keep their order, because in JSON the position of an item in an array is part of its meaning.

Convert a JSON array into a CSV file for Excel or Google Sheets. Nested objects become columns, and formula protection is on by default.

Convert CSV or TSV to JSON objects or arrays. Detects the delimiter, keeps leading zeros in phone numbers and PIN codes, and lists problem rows.

Encode text or files to Base64 and decode Base64 back to text or a downloadable file. Supports UTF-8, URL-safe Base64 and data URIs.