JSON Formatter & Validator

Format, minify, and validate strict JSON directly in your browser.

  • Free
  • No signup
  • Runs in your browser

Strict JSON only. JavaScript numbers cannot preserve integers beyond the safe integer range.

How it works

How to use

Paste strict JSON, then format, minify, or validate it.

Method

The browser parses the JSON before producing normalized output.

Example

Format a compact object into readable indented JSON.

Readable JSON and valid JSON are different checks

Formatting changes whitespace so nested objects and arrays are easier to inspect. Validation answers a different question: whether the input follows JSON syntax at all. Minifying goes the other direction and removes unnecessary whitespace from valid JSON.

SnakTool parses the input before it formats or minifies it. Format writes the parsed value back with two-space indentation, while Minify writes the same parsed value without pretty-printing whitespace. Neither operation is schema validation: syntactically valid JSON can still contain the wrong fields or value types for an API.

The same data, formatted and minified
Formatted:
{
  "user": {
    "id": 42,
    "active": true
  }
}

Minified:
{"user":{"id":42,"active":true}}

Check these JSON syntax errors first

Many invalid documents are only one delimiter or quote away from valid JSON. Standard JSON requires double-quoted object keys and strings, commas between members, and balanced braces and brackets. It does not accept JavaScript-style comments or trailing commas.

Literal values are also strict: true, false and null are lowercase, and JavaScript values such as undefined, NaN and Infinity are not JSON values. When validation fails, inspect the punctuation immediately around the reported position as well as the token named in the error.

ProblemInvalid exampleWhat to check
Trailing comma{"id":1,}Remove the comma before }
Single quotes{'id':1}JSON strings use double quotes
Unquoted key{id:1}Quote the property name
Missing comma{"a":1 "b":2}Separate object members with a comma
Comment{"a":1 /* note */}Standard JSON has no comments
JavaScript literal{"ok":True}Use lowercase true
Non-JSON number{"n":NaN}NaN is not a JSON number

The reported position may be after the real mistake

A parser can only report a problem once the next characters make the syntax impossible to continue. If a comma is missing between two properties, for example, the error may be reported when the parser reaches the second property rather than at the exact place where the comma should have been.

Use the error as a starting point, then inspect the preceding key, value, quote, comma, bracket or brace. For deeply nested API responses and configuration data, formatting a valid smaller fragment can also make the surrounding structure easier to compare.

A JavaScript object literal is not automatically JSON

JSON resembles JavaScript object syntax, but the grammars are not interchangeable. JavaScript can write an object with unquoted identifier keys, single-quoted strings or a trailing comma; strict JSON rejects those forms.

A valid JSON document is not limited to an object. An array, string, number, true, false or null can also be a complete JSON value. What matters is that the entire input follows JSON syntax rather than merely looking object-like.

JavaScript-like input versus strict JSON
Not strict JSON:
{ name: 'Ada', active: true, }

Valid JSON:
{ "name": "Ada", "active": true }

JSONC, JSON5 and NDJSON solve different problems

Files described as JSONC or JSON5 deliberately allow syntax beyond strict JSON, such as comments or other conveniences. NDJSON uses a separate JSON value on each line rather than treating the complete file as one ordinary JSON document.

SnakTool's JSON Formatter & Validator uses the browser's strict JSON parser. Do not assume that a file accepted by a JSONC-, JSON5- or NDJSON-aware application will pass unchanged here. When another program owns the file format, follow that program's specification before removing syntax simply to satisfy a strict JSON validator.

Formatting an API response can reveal structure, not correctness

Pretty-printing a compact API response exposes nesting and array boundaries without adding business rules. That is useful when tracing which object owns a field or comparing a response with API documentation. Minification is useful when you need the parsed JSON serialized without indentation.

Parsing can normalize more than whitespace in edge cases. JavaScript numbers do not represent every integer exactly, so a very large numeric identifier can lose precision before it is written back. Keep identifiers outside the safe integer range as strings at the source when every digit matters. Duplicate object keys should also not be relied on to survive parsing as separate entries.

Compact API response
{"status":"ok","data":{"id":17,"roles":["admin","editor"]}}

Formatting does not repair malformed JSON

The formatter is not an automatic repair engine. Invalid input must parse successfully before SnakTool can produce formatted or minified output, so it will not guess whether a single quote, missing comma or comment was intentional.

The input is also bounded to 1,048,576 UTF-16 code units. For data near that limit, reduce the sample to the failing object or array when possible; a smaller reproducible fragment is usually easier to debug than an entire payload.

Frequently asked questions about JSON Formatter & Validator

Does formatting JSON change the data?

For ordinary JSON values, formatting changes presentation rather than the intended structure. However, parsing and re-serializing has edge cases: very large numeric integers can lose JavaScript number precision, and duplicate object keys should not be expected to remain as separate entries.

Does Validate check an API's required fields?

No. It checks JSON syntax. Required fields, allowed values and object structure need the API's schema or application-level validation.

What does a JSON formatter do?

A JSON formatter parses valid JSON and writes it with consistent indentation and line breaks so nested objects and arrays are easier to read. SnakTool formats with two-space indentation.

What is the difference between JSON beautify and JSON minify?

Beautifying or pretty-printing adds whitespace for readability. Minifying removes unnecessary formatting whitespace. Both operations require valid JSON in this tool.

Why is my JSON invalid?

Common causes include trailing commas, single-quoted strings, unquoted object keys, missing commas, comments, mismatched brackets or braces, and JavaScript-only values such as undefined or NaN.

Can JSON use single quotes?

No. JSON strings and object member names use double quotes. Single-quoted strings belong to other syntaxes, not strict JSON.

Do JSON object keys need double quotes?

Yes. Every object member name in strict JSON is a double-quoted string.

Why can a JSON error appear after the actual mistake?

A parser often detects an error only when later input makes the earlier omission impossible to continue. Check the punctuation and quotes immediately before the reported position as well as the reported token.

What is JSONC, and why can it fail a JSON validator?

JSONC is commonly used for JSON-like data with comments. Comments are not part of standard JSON, so a JSONC document can be valid for a JSONC-aware application and still fail a strict JSON validator.

Can the top level of JSON be an array instead of an object?

Yes. A complete JSON document can be an array. It can also be a string, number, true, false or null; the top level is not restricted to objects.

Is there an input size limit for the JSON formatter?

Yes. The current developer-text limit is 1,048,576 UTF-16 code units. Inputs above that limit are rejected before parsing.

Browse all Developer Tools