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

json-stringify-pretty-compact

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-stringify-pretty-compact

The best of both `JSON.stringify(obj)` and `JSON.stringify(obj, null, indent)`.

  • 3.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1M
increased by2.57%
Maintainers
1
Weekly downloads
 
Created

What is json-stringify-pretty-compact?

The json-stringify-pretty-compact npm package is designed to provide a more compact and human-readable JSON stringification. It aims to strike a balance between readability and compactness by using a more intelligent formatting approach compared to the default JSON.stringify method.

What are json-stringify-pretty-compact's main functionalities?

Compact and Pretty JSON Stringification

This feature allows you to convert a JavaScript object into a JSON string that is both compact and easy to read. The output is more human-friendly compared to the default JSON.stringify method.

const stringify = require('json-stringify-pretty-compact');
const obj = { foo: 'bar', baz: [1, 2, 3], nested: { a: 1, b: 2 } };
console.log(stringify(obj));

Custom Indentation

This feature allows you to specify the number of spaces to use for indentation, giving you control over the readability of the output.

const stringify = require('json-stringify-pretty-compact');
const obj = { foo: 'bar', baz: [1, 2, 3], nested: { a: 1, b: 2 } };
console.log(stringify(obj, { indent: 4 }));

Maximum Line Length

This feature allows you to set a maximum line length for the output, ensuring that the JSON string does not exceed a specified width, which can be useful for maintaining readability in narrow spaces.

const stringify = require('json-stringify-pretty-compact');
const obj = { foo: 'bar', baz: [1, 2, 3], nested: { a: 1, b: 2 } };
console.log(stringify(obj, { maxLength: 80 }));

Other packages similar to json-stringify-pretty-compact

Keywords

FAQs

Package last updated on 20 Feb 2021

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