JSON Formatter & Validator

Paste JSON or open a file — it is validated as you type, with the exact line and column of any error. Pretty-print or minify, sort keys, browse it as a tree, and repair near-JSON with comments, trailing commas or single quotes.

Output

            
            
        

What Is JSON?

JSON (JavaScript Object Notation) is a lightweight, text-based data interchange format that has become the de facto standard for data communication on the web. Originally derived from JavaScript, JSON is language-independent and supported by virtually every modern programming language including Python, Java, C#, Go, Ruby, and PHP.

A JSON document consists of two basic structures: objects (collections of key-value pairs wrapped in curly braces {}) and arrays (ordered lists of values wrapped in square brackets []). Values can be strings, numbers, booleans (true/false), null, or nested objects and arrays. This simplicity is what makes JSON so versatile and ubiquitous in modern software development.

How to Use This JSON Formatter

Paste your JSON into the input field, click Open file…, or drag a .json file onto the box. The JSON is checked as you type: valid input appears formatted and color-highlighted on the right, together with its size, number of keys and nesting depth. Choose 2 spaces, 4 spaces, tabs or a minified single line under Indent, and tick Sort keys A–Z to order every object’s keys alphabetically — useful before comparing two JSON documents in the Diff Checker.

Switch the output to Tree to browse large documents: objects and arrays fold open and closed, and clicking any entry shows its path (for example $.users[0].email) with a button to copy it — handy for writing jq filters, JSONPath queries or JavaScript property access. Copy Output and Download give you the result; Ctrl+Enter formats immediately, which you need for inputs over 500,000 characters, where live checking pauses.

Error Messages You Can Act On

Browsers report JSON errors as “Unexpected token } in JSON at position 1832” — a character offset you then have to count. This formatter uses its own parser and tells you the line and column, shows the line with a marker under the problem, and explains it in plain words. Jump to error in input places the cursor right on it. The most common errors:

  • Trailing comma — {"a": 1,}: JSON does not allow a comma after the last property or array element.
  • Single quotes — {'a': 'b'}: strings and property names need double quotes.
  • Unquoted keys — {a: 1}: valid JavaScript, but not JSON.
  • Comments — // … and /* … */ are not part of JSON (they are allowed in JSON5 and JSONC).
  • Python literals — True, False and None from a Python print() must be true, false and null.
  • Line breaks inside strings — a raw line break must be written as \n; often it means a closing quote is missing.
  • Missing comma or bracket — the message names the object or array and the line where it was opened.

Repair JSON Automatically

If the error is one of the cases above, Repair JSON fixes it for you: it removes comments and trailing commas, converts single quotes to double quotes, quotes bare keys, inserts missing commas between values, replaces True/False/None, undefined, NaN and Infinity with valid JSON, and wraps several JSON documents (for example JSON Lines log output) into one array. It then tells you exactly what it changed, so nothing happens silently. Repair does not guess at missing brackets or truncated input — those it reports as errors, because any guess could change your data.

Large Numbers Stay Exact

JavaScript stores every number as a 64-bit float, so integers above 9,007,199,254,740,991 (253−1) lose precision: JSON.parse('1849302755162840064') returns 1849302755162840000. Many online formatters run your input through JSON.parse() and quietly change IDs from Twitter/X, Discord, databases or payment systems. This formatter keeps every number exactly as written — 1.0 stays 1.0 and long IDs stay intact — and warns you when a number is too large for JavaScript, so you know to send it as a string. It also warns about duplicate keys in the same object, which most parsers accept but resolve by silently keeping only the last value.

Which IDs are affected, and how to keep them exact in JavaScript, Python, Go, Java and jq: Why JSON tools change your numbers.

Stringified JSON Inside a String

Logs, message queues and some APIs deliver JSON that has been encoded twice: "{\"id\":1,\"ok\":true}". That is valid JSON — but only a string. When the formatter sees a string that contains JSON, it offers Parse the JSON inside this string and formats the inner document in one click.

Real-World Use Cases

  • API Development & Debugging — Format API responses to inspect data structures, identify missing fields, and debug integration issues. Most REST APIs return minified JSON that is hard to read without formatting.
  • Configuration File Editing — Many tools use JSON for configuration (package.json, tsconfig.json, .eslintrc). Validate changes before deploying to catch errors early.
  • Database Record Inspection — MongoDB, CouchDB, and other document databases store data as JSON. Format stored documents for easier analysis and debugging.
  • Log Analysis — Structured logging frameworks output JSON log lines. Formatting them makes it easier to trace issues and understand application behavior.
  • Data Transformation — Validate JSON before importing into spreadsheets, databases, or data processing pipelines to avoid downstream errors.

Tips for Working with JSON

  • Always use double quotes for strings and keys — single quotes are not valid JSON.
  • Trailing commas after the last element are a common error — Repair JSON removes them for you.
  • Use null instead of undefined — undefined is not a valid JSON value.
  • For large JSON files (10MB+), consider using command-line tools like jq for better performance.
  • When debugging API responses, check the Content-Type header to ensure the server returns application/json.

Features

  • Live validation — errors with line, column and a plain-language explanation
  • Pretty printing & minifying — 2 spaces, 4 spaces, tabs or one line, with syntax highlighting
  • Sort keys — alphabetical key order for stable diffs
  • Tree view — fold large documents and copy the path of any value
  • Repair — fixes comments, trailing commas, single quotes, unquoted keys and Python literals
  • Exact numbers — big integer IDs are never rounded; duplicate keys are flagged
  • Files — open or drop files up to 50 MB, download the result
  • 100% client-side — your data never leaves your browser

Frequently Asked Questions

Is my data safe?

Yes. Parsing, formatting and repairing all run in your browser with JavaScript. Your JSON is never sent to a server, stored or logged, so you can safely paste API responses that contain tokens or personal data.

What is valid JSON?

Valid JSON must be a properly formatted object (wrapped in curly braces {}) or array (wrapped in square brackets []). Strings must use double quotes. Trailing commas are not allowed. Keys must be unique strings, and all strings must be properly escaped.

What is the difference between JSON and a JavaScript object?

JSON is stricter: keys must be double-quoted strings, no trailing commas, no comments, and no undefined values. JavaScript objects are more flexible but aren’t valid JSON.

Can I format invalid JSON?

Often, yes. Click Repair JSON to fix the most common problems — comments, trailing commas, single quotes, unquoted keys, missing commas and Python’s True/False/None — and the tool lists every change it made. Missing brackets or cut-off input are reported with line and column instead, because guessing could change your data.

Why does my long ID change in other JSON tools?

JavaScript numbers are 64-bit floats and cannot store integers above 9,007,199,254,740,991 exactly, so tools built on JSON.parse() round them. This formatter keeps number literals exactly as written and warns you when a value is too large for JavaScript.

What is the maximum JSON size this tool can handle?

Files up to 50 MB can be opened. Input up to 500,000 characters is validated live as you type; larger documents are formatted when you press Format or Ctrl+Enter, and the tree view loads large arrays in steps of 200 entries so the page stays responsive.

How do I minify JSON for production?

Paste your formatted JSON and click the Minify button. This removes all whitespace, newlines, and indentation while preserving the data exactly. How much smaller the result is depends on how deeply nested and indented the original was; the status line shows the new size.