Json Diff Checker Online – JavaScript JSON Formatting
🧹 Open JSON Formatter Tool
Use Json Diff Checker Online instantly – format, validate, minify, or convert your JSON data.
JavaScript provides a built‑in method JSON.stringify() that can produce pretty‑printed JSON with custom indentation.
Pretty print example
const data = { name: "John", age: 30, city: "New York" };
// Pretty-print with 2 spaces
const prettyJson = JSON.stringify(data, null, 2);
console.log(prettyJson);
/* Output:
{
"name": "John",
"age": 30,
"city": "New York"
}
*/
Minify (remove whitespace)
const minified = JSON.stringify(data);
Read JSON from file (Node.js)
const fs = require('fs');
const data = JSON.parse(fs.readFileSync('data.json', 'utf8'));