Serialize JSON in color.


stars 🌟issues ⚠️updated 🛠created 🐣size 🏋️‍♀️
Minified + gzip package size for @buzuli/json in KB



Serialize JSON in color.


npm install --save @buzuli/json


const json = require('@buzuli/json')
const jsonOptions = { indent: 4 }

console.log(json(require('./package.json'), jsonOptions))



You can disable color via the color option (enabled by default). Set to a falsey value to disable.


You can configure indentation via the indent option. Accepts a boolean, number, or string.

To disable, set to false or a negative number.

To customize then indentation:

  • You can specify a number which is translated as the number of spaces to indent.
  • You can supply a string to replace the default indentation text (two space).


There is a CLI utility paired with this module that is exposed as the command json.

This command has the same configuration options as the utility function.

Just pipe some data to it to format it with friendly colors.

cat package.json | json

Want a flat structure indented?

cat flat.json | json -C

Want an indented structure flattend?

cat indented.json | json -CI

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.