# color-json

> Color JSON in the console with no dependencies

Latest version **3.0.5** (published 2023-02-28) · MIT license · 0 weekly downloads

## Install

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

## Health

**Score 40/100 (D)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 3.0.5 |
| Published | 2023-02-28 |
| First published | 2018-03-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=12 |
| Dependencies | 0 |
| Unpacked size | 6.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 15 |
| Author | Adam Quinton |
| Maintainers | zvakanaka |
| Keywords | color, json, console, terminal |

## Links

- npm: https://www.npmjs.com/package/color-json
- Repository: https://github.com/zvakanaka/color-json
- Homepage: https://github.com/zvakanaka/color-json#readme
- Issues: https://github.com/zvakanaka/color-json/issues
- npm.io page: https://npm.io/package/color-json

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 3.0.5 (latest) — 2023-02-28
- 3.0.4 — 2023-02-28
- 3.0.3 — 2023-02-27
- 3.0.2 — 2023-01-31
- 3.0.1 — 2023-01-31
- 3.0.0 — 2023-01-16
- 2.0.1 — 2020-03-10
- 2.0.0 — 2018-11-06
- 1.0.1 — 2018-05-08
- 1.0.0 — 2018-03-10

## README

Color JSON in the console with no dependencies

![screenshot](https://i.imgur.com/175gebf.png)

## Usage
### Default Usage
```js
import cj from 'color-json';

const topPlanets = [
  {
    "planet": "Saturn",
    "radius": {
      "miles": 36184
    },
    "rings": true,
    "moons": 53
  },
  {
    "planet": "Earth",
    "radius": {
      "miles": 3959
    },
    "rings": null,
    "moons": 1
  }
];

console.log(cj(topPlanets));
```
### Switch Colors
```js
const customColors = {
  separator: 'yellow',
  string: 'yellow',
  number: 'blue',
  boolean: 'magenta',
  null: 'red',
  key: 'green'
};
console.log(cj(topPlanets, customColors));
```
### Customize Colors
```js
const customColorMap = {
  black: '\x1b[38;2;0;0;0m',
  red: '\x1b[38;2;249;133;123m',
  green: '\x1b[38;2;163;238;160m',
  yellow: '\x1b[38;2;209;154;102m',
  blue: '\x1b[36m',
  magenta: '\x1b[38;2;209;154;102m',
  cyan: '\x1b[38;2;75;167;239m',
  white: '\x1b[38;2;219;223;244m'
};
console.log(cj(topPlanets, undefined, customColorMap));
```

### Custom Spacing
```js
console.log(cj(topPlanets, undefined, undefined, 4));
```

## Versions
### 3.0.x
Converted to [ESM](https://github.com/sindresorhus/meta/discussions/15) (`import` instead of `require`).
### 2.x.x 
Use this version if you still need `require` syntax (CommonJS).

## Color Tool
[hex to console color](https://codepen.io/zvakanaka/pen/MVWGJG)

## Credits
[user123444555621](https://stackoverflow.com/a/7220510/4151489) for the syntax highlight regular expressions

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