Skip to content
ByteMath

How do I format and validate JSON?

Paste minified or broken JSON to pretty-print it with 2-space indentation or see the exact error position. Strict RFC 8259 parsing, entirely in your browser.

Last updated:

Inputs

Output

{
  "order": {
    "id": "A-1029",
    "items": [
      {
        "sku": "A-100",
        "qty": 2
      },
      {
        "sku": "A-102",
        "qty": 1
      }
    ],
    "total": 54.8,
    "paid": true
  }
}
Input size
108 B
Output size
213 B
Records
–
Output vs input
197 %

Results are engineering estimates for planning. Final designs must follow your local code and be checked by a qualified professional.

This scenario at a glance

Input
ConversionFormat / validate JSON
CSV delimiterComma (,)
Input{"order":{"id":"A-1029","items":[{"sku":"A-100","qty":2},…
Calculated
Output{ "order": { "id": "A-1029", "items": [ {…
Input size108 B
Output size213 B
Records–
Output vs input197 %

Engineering notes for this workload

Minified JSON from APIs and logs is hard to read. Pasting it here pretty-prints it with two-space indentation, one key per line, so nested structures like the order items in the sample become easy to scan.

The formatter is also a validator. It uses the browser's strict JSON parser, which follows RFC 8259. If the input is invalid, the output shows the parser's error message with the position, for example an unexpected token at line 3, column 12. Common causes are trailing commas after the last item, single quotes instead of double quotes, unquoted keys, comments and NaN or Infinity values, all of which are valid in JavaScript but not in JSON.

JSON5 and JSONC files, such as tsconfig.json or VS Code settings, allow comments and trailing commas. They are not standard JSON, so this validator rejects them. Remove the comments or use a JSON5-aware parser for those files.

Formatting does not change the data. Key order is preserved, and numbers keep their values, but very large integers beyond 2^53, such as 64-bit IDs from some databases, lose precision when parsed by JavaScript. If you see IDs change, have the API send them as strings.

Check the size counters: pretty-printing increases size, often by 20–50 %, because of whitespace. That is fine for reading and debugging, but APIs should send minified JSON and rely on gzip or Brotli compression, which removes most of the difference anyway.

Your JSON never leaves the browser, so it is safe to paste production payloads with personal data for debugging, though it is still good practice to redact secrets.

For recurring checks in a build pipeline, validate JSON with a schema (JSON Schema) and a command-line tool so invalid files fail the build automatically instead of breaking production at runtime, when they are much harder to trace.

Reference table

Data format reference
FormatStandardKey rules
CSVRFC 4180Fields with delimiter, quote or newline are quoted; quotes doubled ("")
CSV (Excel DE/FR/ES)Locale defaultSemicolon delimiter because comma is the decimal separator
JSONRFC 8259UTF-8, double-quoted keys and strings, no trailing commas, no comments
Base64RFC 4648 §4A–Z a–z 0–9 + /, = padding, 4 characters per 3 bytes (+33 %)
Base64urlRFC 4648 §5- and _ instead of + and /, padding often omitted (JWT)

All conversions on this site run locally in your browser.

Questions about this scenario

How do I validate JSON?

Paste it into the formatter. Valid JSON is pretty-printed; invalid JSON shows the parser error and position.

Why is my JSON invalid?

Typical causes are trailing commas, single quotes, unquoted keys, comments or special values like NaN, which JSON does not allow.

Does formatting change my data?

No, but very large integers above 2^53 can lose precision in JavaScript; send such IDs as strings.