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}'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
- Paste or type your JSON into the input box, or press Example to load a sample.
- Choose an indent size and whether to sort object keys alphabetically.
- Press Format to pretty-print it, or Minify to strip all whitespace.
- If the JSON is invalid, the error message shows the line and column where it first goes wrong.
- Copy the result or download it as a .json file.
Examples
Input
{"id":42,"name":"PithLab","tags":["tools","free"]}Output
{
"id": 42,
"name": "PithLab",
"tags": [
"tools",
"free"
]
}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.