With the caveat that I’ve never really used it, the HTML-CSS-JS-Prettify package might do what you want.
A quick install in a Sublime sandbox with all default settings (except for having to customize the path to nodejs
), I was able to convert your sample code into this with a couple of keystrokes:
var object = [{
key1: 'hello',
key2: 'bye'
},
{
key1: 'your',
key2: 'welcome'
}
];
In order to do that I had to first select the JSON object and trigger the command, then select the whole construct and trigger the command again; just selecting the single line didn’t re-flow it. Note also that the opening brace isn’t properly shifted to the correct location.
Possible one or both issues could be resolved by configuring things a little more than they are out of the box.