โšกSwiftKit
โ† All Toolsโ˜• Support
{ }Developer Tools

JSON Formatter & Validator

Clean, minify, and debug JSON payloads with synchronized line numbers and client-side tree navigation.

0 bytes | 0 lines
1

Strict Syntax Pinpointing

Synchronized line counters immediately locate missing quotes, trailing commas, and bad brackets.

Instant File & Drag-and-Drop

Open multi-megabyte log files or configuration documents directly without copying to your clipboard.

Private Browser Execution

Zero server telemetry. Sensitive API tokens, mock database tables, and user records stay entirely in local memory.

The eight JSON mistakes that cause most errors

JSON looks like the objects you write in code, but it is a stricter text format (defined in RFC 8259). Almost every "invalid JSON" message comes from one of these. The third column is what this validator reports for the example, so you can match it to what you see.

Trailing comma
{"name": "Sam", "age": 30,}

You will see: A trailing comma before '}' isn't allowed in JSON

Fix: Delete the last comma. It is the one just before the closing } or ].

Single quotes
{'name': 'Sam'}

You will see: Property names must use double quotes, not single quotes

Fix: Swap every ' for ". JSON allows double quotes only.

Unquoted key
{name: "Sam"}

You will see: Expected a double-quoted property name but found 'n'

Fix: Put the key in double quotes, like "name": "Sam".

Comment
{"name": "Sam" // the user}

You will see: Comments aren't allowed in JSON

Fix: Remove the comment, or keep the note in a separate field.

Missing comma
{"name": "Sam" "age": 30}

You will see: Expected ',' or '}' after this property, but found '"'

Fix: Add a comma between the two items.

undefined or NaN
{"score": undefined}

You will see: 'undefined' is not valid in JSON (use null)

Fix: Use null for a missing value. NaN and Infinity are not valid either.

Leading zero
{"zip": 02134}

You will see: Invalid number: numbers cannot have leading zeros

Fix: If it is an identifier such as a postcode, make it a string: "02134".

Mismatched bracket
{"items": [1, 2, 3}

You will see: Expected ',' or ']' after this array item, but found '}'

Fix: Close the [ with a ] before closing the { with a }.

Every message also shows a line and column, and the line numbers in the editor match them.

What counts as valid JSON

A JSON document is one value, and a value is one of six things:

Objects and arrays can nest inside each other as deep as you like, which is why the tree viewer is handy for reading a large file. Spaces, tabs and line breaks between values are ignored, so formatting changes how it looks and not what it means.

Format or minify? A worked example

Here is the same small record laid out two ways. They hold exactly the same data.

Formatted: 151 characters
{
  "id": 1042,
  "name": "Sam Rivera",
  "active": true,
  "tags": ["admin", "beta"],
  "address": {
    "city": "Perth",
    "postcode": "6000"
  }
}
Minified: 114 characters
{"id":1042,"name":"Sam Rivera","active":true,"tags":["admin","beta"],"address":{"city":"Perth","postcode":"6000"}}

Minifying removed 37 characters, about a quarter, just by taking out spaces and line breaks. On a large payload that adds up, which is why web services often send the minified form. Use Format when a person needs to read or edit it, such as debugging an API response or checking a config file, and Minify when it is going over a network or into a small field. The 2-space and 4-space buttons only change how far the indents go.

Why this formatter keeps your numbers and keys exactly as typed

Many online formatters run your text through the browser's built-in parser and then write it back out. That round trip can quietly change the data:

This tool reads your text itself, keeps every number and string as written, keeps keys in your order, and warns you when a key repeats. Only the whitespace changes. If you are checking an API response or a saved file, what you read here is what is in the file.

Related: compare two JSON files with the diff checker, encode a value with the Base64 and URL encoder, turn a timestamp into a date with the epoch converter, or generate IDs with the UUID generator.

Knowledge Base

Frequently Asked Questions

Is my JSON data secure and private?โ–ผ

Yes. All validation, parsing, formatting, and tree-building execute strictly in your browser memory. Nothing is sent to an external server or logged.

Can I upload large JSON files?โ–ผ

Yes. You can drop any .json, .txt, or .log file directly into the editor or click 'Upload File'. The browser parses it directly via local memory without uploading to a server.

How does the validator pinpoint syntax errors?โ–ผ

The built-in parser inspects error tokens, trailing commas, unmatched brackets, and character offsets to identify the exact line number and column where syntax broke.

Why does my JSON fail when it works in my code?โ–ผ

Code editors and JavaScript itself accept things that real JSON does not: single quotes, unquoted keys, comments, trailing commas and values such as undefined or NaN. JSON is stricter, which is why a file that runs fine in a script can be rejected by a validator, an API or a config loader. The table on this page lists the usual culprits and the fix for each.

Can JSON contain comments?โ–ผ

No. The JSON standard (RFC 8259) has no comment syntax, so // and /* */ are errors. If you need notes, either keep them in a separate file, or add a field that is just for notes, such as a key called "_comment". Some tools read a relaxed dialect called JSONC or JSON5 that allows comments, but a strict validator will reject it.

What is the difference between JSON and a JavaScript object?โ–ผ

JSON is a text format based on JavaScript object syntax, but it is much stricter. Keys must be in double quotes, strings must use double quotes, and there are no functions, comments, trailing commas or undefined values. A JavaScript object lives in memory, and JSON is the text you send or save.

Does formatting change my data?โ–ผ

No. This tool only changes the whitespace between values. Numbers and strings are kept exactly as you typed them, and keys stay in the order you wrote them. That differs from many online formatters that rewrite the JSON through the browser's own parser, which can quietly round long numbers and drop repeated keys. See the section on exact numbers below.