TBToolbox
Developer Tools

JSON Formatter & Validator

Paste compact or irregularly spaced JSON to validate its syntax and produce a consistently indented representation. Objects, arrays, strings, numbers, booleans, and null retain their data meaning; only insignificant whitespace changes. Parsing and formatting run locally, so API responses and configuration fragments are not uploaded.

Runs locally — files stay on your device
Quick answer

What does JSON formatting change?

It adds consistent indentation and line breaks without changing the parsed data values.

Formatting JSON without changing its data

JSON is a text syntax for structured values. Whitespace outside strings is insignificant, so indentation and line breaks can be changed without changing the parsed arrays, objects, or primitive values. Formatting necessarily validates because invalid JSON cannot be parsed into a value.

How it works

The tool parses the input with JSON.parse and serializes the resulting value with JSON.stringify using two-space indentation. Syntax errors are reported instead of guessing a repair.

Key concepts

Syntax versus schema

Parsing checks JSON grammar. It does not prove that required application properties or value ranges are correct.

Whitespace

Spaces and line breaks outside quoted strings do not alter the parsed value.

JSON data types

JSON supports objects, arrays, strings, numbers, booleans and null; it has no native Date, BigInt, comment or function syntax.

When to use it

  • Read a minified API response during debugging.
  • Normalize a configuration file before code review.
  • Confirm that copied JSON is syntactically valid.
  • Expose nesting and array boundaries in logged payloads.

When not to use it

  • Do not paste JavaScript object literals with comments or functions.
  • Do not expect formatting to validate a business schema.
  • Do not use it when property order or exact original whitespace is evidence.

Worked examples

Compact API object

Input
{"id":42,"active":true}
Expected output
{ "id": 42, "active": true }

Two-space indentation exposes each property.

Nested response

Input
{"user":{"name":"Ana","roles":["editor","reviewer"]}}
Expected output
A multi-line object with the user object and roles array indented by level.

Nesting becomes easier to scan.

Top-level array

Input
[{"sku":"A1"},{"sku":"B2"}]
Expected output
A formatted array containing two indented objects.

JSON does not require the top level to be an object.

Whitespace normalization

Input
{ "count" : 3 }
Expected output
{ "count": 3 }

Insignificant whitespace is replaced consistently.

Invalid trailing comma

Input
{"id":42,}
Expected output
Syntax error

Trailing commas are not part of JSON grammar.

Common mistakes

Using single quotes

JSON strings and property names require double quotes. Correction: Replace JavaScript-style single quotes with valid JSON double quotes.

Leaving a trailing comma

Unlike some programming-language object literals, JSON forbids trailing commas. Correction: Remove the comma after the final item.

Adding comments

Standard JSON has no comment syntax. Correction: Store explanation outside the JSON or use a format that supports comments.

Confusing validation with schema checking

Valid syntax can still omit required application fields. Correction: Use a JSON Schema validator for structural requirements.

Expecting special JavaScript values

undefined, NaN, Infinity and BigInt are not JSON values. Correction: Represent them with an agreed string, number, or null policy.

Best practices

  • Keep machine-generated JSON valid before formatting.
  • Review strings containing escape sequences after formatting.
  • Use schema validation separately when an API contract matters.

Related operations and differences

JSON Validator

Use it when you only need a validity result rather than reformatted output.

JSON Minifier

Minification removes unnecessary whitespace for compact transfer or storage.

Limitations and privacy

  • Numbers are parsed with JavaScript number semantics, so extremely large integers can lose precision.
  • Formatting does not preserve original spacing or guarantee application-specific property order.

Processing uses browser APIs on this device; the entered content is not sent to the Toolbox server.

Frequently asked questions

Does formatting change JSON values?

It changes insignificant whitespace, not the parsed data values.

Does the formatter also validate?

Yes. Formatting begins with parsing, and invalid JSON produces an error.

Why are comments rejected?

Comments are not part of the standard JSON grammar.

Can the top level be an array?

Yes. A JSON text can represent an array or another JSON value.

Will property order be preserved?

Common string-key order is generally retained by JavaScript serialization, but consumers should not rely on object order as data meaning.

Is this JSON Schema validation?

No. It checks grammar, not required properties or business constraints.

References