node package manager

sort-json

Takes a json-file and return a copy of the same file, but sorted

sort-json

Takes a json-file and return a copy of the same file, but with the keys sorted

[sudo] npm -g install sort-json

var sortJson = require('sort-json');
 
var copy = sortJson(object);

sort-json file.json

For now sort-json takes no other arguments, so the original file will be overwritten by a sorted json file, keeping the indentation of the original file.