calculate.sh DE

This tool runs in your browser using JavaScript. If it does not appear, please enable JavaScript or reload the page. The description below explains how it works.

JSON Formatter

Validate, pretty-print, or minify JSON in your browser. Paste JSON into the input box and the tool parses, formats, and reports precise errors as you type - nothing is sent anywhere, so you can safely work with API responses, config files, or data exports that contain sensitive values.

What is JSON?

JSON (JavaScript Object Notation) is the standard text format for exchanging data between programs. It is built from two structures:

  • Objects - key/value pairs in braces, like {"name": "calculate.sh", "tools": 9}.
  • Arrays - ordered lists in brackets, like ["json", "hash", "uuid"].

Values can be strings, numbers, true, false, null, or nested objects and arrays - which is what makes JSON recursive and compact. You see it every day: REST and GraphQL API responses, configuration files (ESLint, TypeScript, VS Code settings), database exports, and web storage all use it.

How to use

Paste JSON into the left panel. The tool parses it live and updates the right panel as you type.

  • Format - pretty-prints the JSON with a configurable indentation: 2 spaces, 4 spaces, or a tab. The classic 8-4-4-4-12 layout for readable diffs and debugging.
  • Minify - compacts the input to a single line, stripping all whitespace. This is the form to use for a file you plan to parse programmatically or paste into a URL payload.

Errors with line and column

JSON is a strict format by design. Comments, trailing commas, single quotes, and unquoted keys are all intentionally rejected - the same way the JSON spec requires. When the input is invalid, the tool reports the problem with a precise line and column so you can jump straight to the offending spot. Line numbers stay correct even with Windows-style CRLF line endings.

Duplicate keys

If an object contains the same key twice, the tool shows an amber warning below the output (Duplicate key …). Per the JSON specification the last value wins and no error is raised; the warning simply makes that silently-surprising behavior visible - useful when you merge data from different sources and want to notice collisions.

What to know

  • Top-level values can be anything valid JSON: objects, arrays, strings, numbers, true, false, or null.
  • Number precision - values are handled as JavaScript numbers (standard JSON behavior), so integers beyond 2⁵³ (≈9 quadrillion) may lose precision. The formatting is equivalent to JSON.parse + JSON.stringify under the hood.
  • Empty or whitespace-only input is not an error - you just get the hint text until there is something to format.

Example

Minified JSON like {"host":"api.example.com","port":443,"tls":true} becomes, with 2-space indentation:

{
  "host": "api.example.com",
  "port": 443,
  "tls": true
}

Use Format to make a response readable before you paste it into documentation or a ticket, then Minify again once you are finished editing it.