Skip to content
PithLab

↑↓ to move · Enter to open · Esc to close

JSON Formatter and Validator

Beautify, minify and validate JSON with exact error locations.

Use via API

Validate and pretty-print or minify JSON. Send JSON, get JSON back.

POST https://pithlab.com/api/v1/tools/json-formatter

curl https://pithlab.com/api/v1/tools/json-formatter \
  -H "Authorization: Bearer $PITHLAB_KEY" \
  -H "Content-Type: application/json" \
  -d '{"input":"{\"b\":1,\"a\":[true,null]}","sortKeys":true}'

Fields and responseOpenAPI documentGet an API key

About the JSON Formatter

Format, beautify, minify and validate JSON in your browser. Pinpoints syntax errors by line and column, and can sort keys. Your data never leaves your device.

How to use the JSON Formatter

  1. Paste or type your JSON into the input box, or press Example to load a sample.
  2. Choose an indent size and whether to sort object keys alphabetically.
  3. Press Format to pretty-print it, or Minify to strip all whitespace.
  4. If the JSON is invalid, the error message shows the line and column where it first goes wrong.
  5. Copy the result or download it as a .json file.

Examples

Pretty-print a compact API response

Input

{"id":42,"name":"PithLab","tags":["tools","free"]}

Output

{
  "id": 42,
  "name": "PithLab",
  "tags": [
    "tools",
    "free"
  ]
}
Catch a trailing comma

Input

{"a": 1, "b": 2,}

Output

Trailing commas are not allowed at line 1, column 17.

Frequently asked questions

Is my JSON sent to a server?

No. Formatting and validation run entirely in your browser using JavaScript, so the JSON you paste is never uploaded.

Why is my JSON invalid when it works in JavaScript?

JSON is stricter than JavaScript object syntax. Keys and strings must use double quotes, trailing commas are not allowed, and comments, undefined, NaN and functions are not valid JSON values.

Does sorting keys change my data?

Sorting only reorders object keys alphabetically at every level. Values and array order stay exactly the same.

How large a file can I format?

It is limited only by your device's memory. Several megabytes of JSON format almost instantly on a typical laptop.

Guides that use this tool

  • JSON vs YAML: when to use which

    JSON and YAML describe the same data, but they fail in different ways. A practical guide to choosing between them, with the YAML gotchas that bite in production.