Validate, format, and minify JSON. Paste your JSON below.
JSON (JavaScript Object Notation) is a lightweight, text-based data interchange format that is easy for humans to read and write, and easy for machines to parse and generate. Despite its name, JSON is language-independent and is used across virtually every programming language and platform.
JSON was derived from JavaScript object literal syntax but has become a standard in its own right (ECMA-404 and RFC 8259). It is the dominant format for REST API responses, configuration files (like package.json, tsconfig.json), and data storage in document databases like MongoDB and CouchDB.
JSON supports six data types: strings (double-quoted), numbers (integer or floating-point), booleans (true/false), null, arrays (ordered lists), and objects (key-value pairs). Unlike JavaScript, JSON does not allow functions, dates, undefined, comments, or trailing commas.
{"a": 1,} is invalid{'key': 'value'} is invalid{key: "value"} is invalid// comments or /* block comments */undefined, NaN, and Infinity are not valid JSONfunction isValidJSON(str) {
try {
JSON.parse(str);
return true;
} catch (e) {
console.error('JSON parse error:', e.message);
return false;
}
}
// Pretty print JSON
const formatted = JSON.stringify(obj, null, 2);
// Minify JSON
const minified = JSON.stringify(obj);
import json
def is_valid_json(s):
try:
json.loads(s)
return True
except json.JSONDecodeError as e:
print(f"JSON error at line {e.lineno}, col {e.colno}: {e.msg}")
return False
# Pretty print
formatted = json.dumps(obj, indent=2)
# Minify
minified = json.dumps(obj, separators=(',', ':'))
package main
import (
"encoding/json"
"fmt"
)
func isValidJSON(s string) bool {
var js json.RawMessage
return json.Unmarshal([]byte(s), &js) == nil
}
// Pretty print
formatted, _ := json.MarshalIndent(obj, "", " ")
// Minify
minified, _ := json.Marshal(obj)
# Validate and pretty print
echo '{"name":"test"}' | jq .
# Minify
echo '{"name": "test"}' | jq -c .
# Validate a file
jq . config.json > /dev/null && echo "Valid" || echo "Invalid"
# Extract a field
curl -s https://api.example.com/data | jq '.results[0].name'
| Feature | JSON | XML | YAML |
|---|---|---|---|
| Readability | Good | Verbose | Excellent |
| Comments | No | Yes | Yes |
| Data types | 6 types | All strings | Rich types |
| API usage | Dominant | Legacy/SOAP | Rare |
| Config files | Common | Some | Common |
JSON.parse() converts a JSON string into a JavaScript object or value. JSON.stringify() does the opposite - it converts a JavaScript object into a JSON string. You use parse() when receiving data (e.g., from an API response) and stringify() when sending data (e.g., in a request body). Both will throw errors on invalid input: parse() throws on malformed JSON, and stringify() throws on circular references.
jq and certain parsers support a non-standard "JSON with comments" mode, but it is not part of the official spec.
"2026-02-14T12:00:00Z", which are human-readable and supported by new Date() in JavaScript and datetime.fromisoformat() in Python. Another option is Unix timestamps (seconds since epoch), which are compact but less readable. Choose ISO 8601 for APIs consumed by humans and timestamps for machine-to-machine communication.
JSON.parse() can typically handle strings up to several hundred MB. Most web servers limit request body size (nginx defaults to 1 MB, Express defaults to 100 KB). For very large datasets, consider streaming JSON parsers like JSONStream in Node.js or json.Decoder in Go, which process data incrementally without loading the entire document into memory.
Ensure your APIs return valid JSON responses 24/7. Get alerted when endpoints return malformed data or error status codes.
Start monitoring free →