Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

prettyjson

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prettyjson

Package for formatting JSON data in a coloured YAML-style, perfect for CLI output

  • 0.3.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
761K
decreased by-7.99%
Maintainers
1
Weekly downloads
 
Created

What is prettyjson?

The prettyjson npm package is a utility for formatting JSON data in a human-readable way. It provides a simple and customizable way to print JSON objects with colors and indentation, making it easier to debug and visualize JSON data.

What are prettyjson's main functionalities?

Basic JSON Formatting

This feature allows you to format a JSON object into a more readable string with indentation and colors. The example code demonstrates how to use prettyjson to render a simple JSON object.

const prettyjson = require('prettyjson');
const data = { name: 'John', age: 30, city: 'New York' };
console.log(prettyjson.render(data));

Customizing Colors

This feature allows you to customize the colors used for keys and values in the formatted JSON output. The example code shows how to set custom colors for keys and string values.

const prettyjson = require('prettyjson');
const data = { name: 'John', age: 30, city: 'New York' };
const options = { keysColor: 'red', stringColor: 'blue' };
console.log(prettyjson.render(data, options));

Rendering Arrays

This feature supports rendering arrays of JSON objects in a readable format. The example code demonstrates how to use prettyjson to render an array of JSON objects.

const prettyjson = require('prettyjson');
const data = [ { name: 'John', age: 30 }, { name: 'Jane', age: 25 } ];
console.log(prettyjson.render(data));

Other packages similar to prettyjson

Keywords

FAQs

Package last updated on 23 Jan 2012

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc