# jsoncolor

> Configurable and simple JSON colorizer

Latest version **0.0.2** (published 2018-04-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install jsoncolor
pnpm add jsoncolor
yarn add jsoncolor
bun add jsoncolor
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2018-04-18 |
| First published | 2018-04-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 34.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | David Konsumer |
| Maintainers | konsumer |
| Keywords | json, syntax, highlite, color, colorizer |

## Links

- npm: https://www.npmjs.com/package/jsoncolor
- Repository: https://github.com/konsumer/jsoncolor
- Homepage: https://github.com/konsumer/jsoncolor#readme
- Issues: https://github.com/konsumer/jsoncolor/issues
- npm.io page: https://npm.io/package/jsoncolor

## Dependencies (1)

- [chalk](https://npm.io/package/chalk.md) ^2.4.0

## 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

- 0.0.2 (latest) — 2018-04-18
- 0.0.1 — 2018-04-18

## README

# jsoncolor

Configurable and simple JSON colorizer

I had various issues with other JSON-color libraries (they choke on certain characters, etc.) I wanted something lightweight, easily configurable and simple that works, so I made this.

It handles JSON, and JSON-serializable objects.

## installation

```sh
npm i jsoncolor
```

## usage

```js
const jsoncolor = require('jsoncolor')
console.log(jsoncolor(process.env))
```

You can also change the colors. Just set the right fields in `colors` to functions that colorize your text. These are the defaults, but you can use anything:

```js
jsoncolor.colors = {
  number: chalk.hex('#ff6188'),
  key: chalk.hex('#ffd866'),
  string: chalk.hex('#a9dc76'),
  boolean: chalk.hex('#ab9df2'),
  null: chalk.hex('#ab9df2')
}
```

If you wanted to use more basic colors:

```js
jsoncolor.colors = {
  number: chalk.red,
  key: chalk.magenta,
  string: chalk.green,
  boolean: chalk.blue,
  null: chalk.cyan,
}
```

If you wanted to output HTML:

```js
jsoncolor.colors = {
  number: o => `<span class="number">${o}</span>`,
  key: o => `<span class="key">${o}</span>`,
  string: o => `<span class="string">${o}</span>`,
  boolean: o => `<span class="boolean">${o}</span>`,
  null: o => `<span class="null">${o}</span>`
}
```

if you don't care about colors or JSON at all:

```js
jsoncolor.colors = {
  number: o => `NUMBER(${o})`,
  key: o => `KEY(${o})`,
  string: o => `STRING(${o})`,
  boolean: o => `BOOLEAN(${o})`,
  null: o => `NULL`,
}
```

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