JSON Formatter & Validator

Format, minify and validate JSON right in your browser. Paste or upload a JSON document, pick an indentation level to beautify it, check the syntax with an exact line and column when something is wrong, sort object keys recursively, escape or unescape strings, then copy or download the result. Everything runs locally — your data is never uploaded.

Input
Output

About this tool

JSON (JavaScript Object Notation) is a lightweight data-interchange format that is easy for humans to read and write, and easy for machines to parse and generate. It is the most common format for configuration files, API requests and responses, and data storage.

This tool parses your JSON with the browser built-in JSON parser, so validation is exactly as strict as the parser used by JavaScript itself. Formatting adds indentation for readability, minifying removes all unnecessary whitespace, sorting reorders object keys alphabetically throughout the whole document, and escaping turns a JSON document into a string literal that can be embedded in another document.

JSON shows up almost everywhere in modern software: REST and GraphQL responses, configuration files, package manifests, log entries, browser storage and NoSQL documents. Because it is read by both people and machines, two styles coexist. Formatted JSON with two-space indentation is the convention in source control, documentation and debugging, while minified JSON is used on the wire, where every whitespace character costs bandwidth. This tool lets you move between the two without installing anything.

The JSON specification is deliberately small. A value can only be an object, an array, a string, a number, true, false or null. Strings must use double quotes, numbers follow the IEEE 754 double-precision format, and keys must be strings. That last detail explains a common surprise: integers above 2^53 lose precision, so a database ID such as 9007199254740993 cannot be represented exactly and should be transported as a string. Duplicate keys are also legal in the grammar but the last one wins, which can silently hide data.

JSON is often confused with its dialects. JSON5 and JSONC allow comments, trailing commas and single quotes for configuration files; NDJSON stores one independent JSON value per line for streaming; YAML is a different format with similar data structures. This validator implements strict JSON only, exactly like JSON.parse, so a document accepted here will be accepted by every standards-compliant parser. That strictness is a feature: catching a trailing comma locally is much cheaper than debugging an API request that returns 400 in production.

How to use

  1. Input: paste your JSON into the left pane, click “Load file” to open a .json file, or drag a file onto the input area.
  2. Indentation: choose 2, 4, 6 or 8 spaces for the formatted output.
  3. Format: pretty-print the JSON using the selected indentation.
  4. Minify: strip all unnecessary whitespace so the output is a single compact line.
  5. Validate: check the syntax without changing the output, and see the exact line and column when something is wrong.
  6. Sort keys: reorder object keys alphabetically, recursively through the whole document. Array elements keep their order.
  7. Escape / Unescape: turn the input into an escaped string literal, or decode an escaped string back into readable JSON.
  8. Copy or download the result, or clear both panes and start again.
  9. Sort keys before committing: alphabetical keys make git diffs readable and stop a reordered object from looking like a large change. Only object keys are reordered; array order, which is meaningful, is preserved.
  10. Minify before embedding: when a JSON document is placed inside an environment variable, a query string or a single-line log field, minify it first so line breaks and indentation do not break the surrounding format.

Frequently asked questions

Is my JSON uploaded to a server?

No. Parsing, formatting and validation all happen in your browser with JavaScript. Nothing is sent over the network, and the content disappears as soon as you close or refresh the page.

What causes the “Invalid JSON” error?

The most common causes are a trailing comma after the last item, unquoted or single-quoted object keys, comments, and values such as NaN, Infinity or undefined that are not valid JSON. The error message tells you the exact line and column so you can fix it quickly.

How is JSON different from JavaScript object syntax?

JSON is a subset of JavaScript. Keys and strings must use double quotes, numbers cannot have a leading plus sign or leading zeros, and comments, functions and undefined are not allowed. Trailing commas are forbidden as well.

Does sorting keys change the data?

No. Reordering object keys does not change the meaning of the data, because JSON objects are unordered collections. Only object keys are reordered — array elements keep their original order.

When should I escape a JSON string?

Escaping is useful when you need to embed a whole JSON document inside a string field of another JSON document, or inside code and log lines. Unescaping reverses the operation, turning the escaped literal back into readable, formatted JSON.

Why did a long number such as a database ID change?

JavaScript numbers are IEEE 754 doubles, which represent integers exactly only up to 2^53 − 1 (9007199254740991). Anything larger is rounded when parsed. If an identifier exceeds that range, store and transmit it as a quoted string rather than a number.

Can the validator read JSON with comments or trailing commas?

No, and that is intentional. Comments and trailing commas belong to JSONC or JSON5, not to standard JSON, and strict parsers reject them. Remove the comments and the final comma before validating — or keep such files as YAML if you need annotations.

Is there a size limit for the document?

There is no fixed limit, but everything runs in the browser tab, so a file of tens of megabytes can become slow and memory-hungry. For very large files, use “Load file” instead of pasting, minify first, and close other heavy tabs.

What is the difference between escaping and minifying?

Minifying removes whitespace but keeps valid JSON. Escaping turns the whole document into a single string literal with escaped quotes and newlines, which is what you need when embedding JSON inside another JSON string, a shell command or a log line. Unescape reverses that operation.

Does sorting keys change the meaning of the data?

No. A JSON object is an unordered collection of key/value pairs, so reordering its keys cannot change its meaning. Array elements keep their positions because array order is significant.