json-format Format and pretty-print JSON
Flags
--indent number default: 2
Examples
Pretty-print a compact JSON object
Usage
"{"name":"Alice","age":30,"roles":["admin","editor"]}" | json-format Format an analytics API response so it's readable
Usage
"{"campaign":"Summer 2025","clicks":4821,"conversions":312,"c..." | json-format Make a server status JSON config human-readable
Usage
"{"server":"prod-1","status":"healthy","uptime":99.97,"region..." | json-format View source
(input, opts = {})=>{
try {
return JSON.stringify(JSON.parse(input), null, parseInt(opts.indent) || 2);
} catch (e) {
return `Error: ${e.message}`;
}
}