JSON formatter

JSON formatter

Pretty-print / minify / validate JSON with error location

Computed in your browser

Paste JSON and choose Pretty-print, Minify or Validate. Represent large integers as strings when their exact digits must be preserved.

 

Example

Input

{"name":"Dayeku","items":[1,2]}

Example result

{
  "name": "Dayeku",
  "items": [
    1,
    2
  ]
}

Choose two-space indentation. Minifying removes structural whitespace, not spaces inside strings.

Technical details & limits

The tool uses JSON.parse and JSON.stringify. Standard JSON requires double-quoted keys and strings and disallows comments, trailing commas and undefined. Numbers use JavaScript Number, so integers beyond 2^53−1 may lose precision. Duplicate keys retain their last value; formatting is not byte-preserving.

About this tool

Validate, pretty-print or minify JSON with two spaces, four spaces or tabs. Inspect API responses, clean up configuration and locate syntax errors locally in the browser.

Use cases

  • Blow up a compact API response so you can read the field structure.
  • Minify a large config for use in an environment variable or URL.
  • Validate a JSON document and see where it fails.

How to use

  1. Paste JSON into the input box.
  2. Pick indent width: 2 spaces, 4 spaces or Tab.
  3. Click Pretty-print, Minify or Validate. Invalid input shows a syntax hint; when the browser provides an error position, the tool also shows line, column and nearby text.

Input & output

Input
Any JSON text. The tool does not accept JavaScript object literals.
Output
A normalised JSON string (pretty or minified).

Notes

Follows the JSON spec: no comments, no trailing commas. Numbers larger than JavaScript’s safe-integer range (2^53) may lose precision — carry them as strings if you need exactness.

FAQ

Does the JSON formatter support comments and trailing commas?
This formatter accepts standard JSON, which does not permit comments or trailing commas. Object names must use double quotes; for example, {"a":1,"b":2} is valid input. A JavaScript object literal may contain syntax that JSON does not allow. Remove unsupported syntax before formatting and preserve a copy of the original when investigating errors, because parsing can also affect duplicate keys and numeric values outside the safe integer range.
Why can JSON formatting change a large integer?
JSON formatting uses JavaScript number parsing, so an integer outside the safe range can lose precision. The largest safe integer is 9007199254740991, which is 2 raised to the power of 53 minus 1. Store identifiers such as order numbers as quoted strings when exact digits matter. Formatting is therefore not a byte-preserving operation, and an already rounded parsed value cannot recover the original digits automatically.
Why does JSON formatting keep only the last duplicate key?
This formatter keeps the last value when an object contains duplicate keys, because that is how its JSON parser constructs the object. For example, {"a":1,"a":2} retains the value 2 for a. The formatted output no longer records the earlier value. Keep the unparsed original when working with logs, signatures, or forensic comparisons, where the exact sequence of keys and bytes may be significant.

Related tools

JSON formatter · Pretty-print / minify / validate JSON with error location
JSON formatter — Tool illustration · dayeku.com