# format-json

> A JSON formatter module for various text/plain serialization styles

Latest version **1.0.3** (published 2013-12-29) · 0 weekly downloads

## Install

```sh
npm install format-json
pnpm add format-json
yarn add format-json
bun add format-json
```

Provides the command `format-json`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2013-12-29 |
| First published | 2013-12-19 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 21 |
| Author | Johan Sundström |
| Maintainers | ecmanaut |

## Links

- npm: https://www.npmjs.com/package/format-json
- Repository: https://github.com/johan/format-json
- Issues: https://github.com/johan/format-json/issues
- npm.io page: https://npm.io/package/format-json

## Recent versions

- 1.0.3 (latest) — 2013-12-29
- 1.0.2 — 2013-12-19
- 1.0.1 — 2013-12-19
- 1.0.0 — 2013-12-19

## README

format-json
===========

A JSON formatter module for various text/plain serialization styles

```javascript
> var json = require('format-json');
> var data = {test: "for example", some: [{nested:0, things: []}, {}]};
> console.log(json.diffy(data));
{ "test": "for example"
, "some":
  [ { "nested": 0
    , "things": []
    }
  , {}
  ]
}
> console.log(json.plain(data));
{
  "test": "for example",
  "some": [
    {
      "nested": 0,
      "things": []
    },
    {}
  ]
}
> console.log(json.terse(data));
{"test":"for example","some":[{"nested":0,"things":[]},{}]}
> console.log(json.space(data));
{ "test": "for example", "some": [ { "nested": 0, "things": [] }, {} ] }
> console.log(json.lines(data));
{ "test": "for example"
, "some": [ { "nested": 0, "things": [] }, {} ]
}
```

### Why?

For short: diffs in version controlled JSON is what prompted `json.diffy`.

The comma-first style may look wonky at first, but it's a compromise that helps
produce diffs where a change (addition, change or deletion) of one property has
no affect on surrounding lines to reduce the amount of diff noise.

Having used this format for a while now, I also appreciate how you get straight
left margins for Objects and Arrays alike.

Not convinced? Then please don't use it! :-)

---
_Source: https://npm.io/package/format-json · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
