
Company News
Socket Joins New OpenJS Program to Fund Node.js Security Work
Socket is joining the OpenJS Security Stewardship Program to fund Node.js vulnerability research, maintainer remediation, and security releases.
devkits-json-formatter
Advanced tools
Format, validate, and minify JSON. Syntax error detection with position info. Zero-dependency JSON utility for developers.
Format, validate, and minify JSON. Syntax error detection with position info. Zero-dependency JSON utility for developers.
Get access to 20+ premium tools including SQL to Code, Data Faker, JWT Generator, and more — all for $9 one-time.
💡 Pay with Crypto: BTC, ETH, USDT (TRC-20), SOL accepted. View crypto addresses
This package is part of DevKits — 82+ free developer tools. The online JSON Formatter includes schema validation, tree view, and query/filter tools.
npm install @devkits/json-formatter
const {
format,
minify,
isValid,
pretty,
countKeys,
getSizeInfo,
sortKeys,
formatSorted
} = require('@devkits/json-formatter');
const uglyJson = '{"name":"John","age":30,"city":"NYC"}';
// Format JSON with indentation
const result = format(uglyJson, { indent: 2 });
// {
// success: true,
// result: '{\n "name": "John",\n "age": 30,\n "city": "NYC"\n}'
// }
// Minify JSON
const min = minify(uglyJson);
// { success: true, result: '{"name":"John",...}', saved: 15 }
// Validate JSON
isValid('{"valid": true}');
// { valid: true }
isValid('{invalid}');
// { valid: false, error: 'Unexpected token...', position: {line: 1, column: 2} }
// Pretty print an object
pretty({ name: 'John', age: 30 });
// '{\n "name": "John",\n "age": 30\n}'
// Count keys recursively
const nested = { a: { b: { c: 1 } }, d: [1, 2, 3] };
countKeys(nested);
// 5
// Get size info
getSizeInfo(uglyJson);
// { original: 36, minified: 36, saved: 0, keys: 3 }
// Sort keys alphabetically
const unsorted = { z: 1, a: 2, m: 3 };
sortKeys(unsorted);
// { a: 2, m: 3, z: 1 }
// Format with sorted keys
formatSorted('{"z":1,"a":2}', 2);
// { success: true, result: '{\n "a": 2,\n "z": 1\n}' }
format(jsonString, options)Formats JSON with specified indentation (default: 2 spaces).
Returns {success, result?, error?}.
minify(jsonString)Removes all whitespace from JSON.
Returns {success, result?, error?, saved?}.
isValid(jsonString)Validates JSON syntax with optional error position.
Returns {valid, error?, position?}.
pretty(obj, indent)Pretty prints a JavaScript object as JSON string.
countKeys(obj)Counts all keys in an object recursively.
getSizeInfo(jsonString)Returns size statistics: original size, minified size, bytes saved, key count.
sortKeys(obj)Returns new object with keys sorted alphabetically (recursive).
formatSorted(jsonString, indent)Formats JSON with keys sorted alphabetically.
MIT
FAQs
Format and validate JSON from CLI or stdin — pretty print, minify, and validate JSON files
The npm package devkits-json-formatter receives a total of 9 weekly downloads. As such, devkits-json-formatter popularity was classified as not popular.
We found that devkits-json-formatter demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.

Company News
Socket is joining the OpenJS Security Stewardship Program to fund Node.js vulnerability research, maintainer remediation, and security releases.

Security News
Two compromised GitHub Actions were re-enabled with malicious tags intact, exposing thousands of downstream repositories to Mini Shai-Hulud.

Research
/Security News
A malicious Firefox extension fetches its payload after installation to evade detection, steal Google session cookies, and automate account takeover.