Roine

Pretty print JSON in a file

February 14, 2019

If you try to dump an object in a JSON and for some reason want it to be formatted use this snippet

fs.writeFile('manifest.json', JSON.stringify(res, null, 4), 'utf8', (err) => {
  //...
})

This will add jump line and 4 space indentation after each entry