JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 142999
  • Score
    100M100P100Q185004F
  • License ISC

Color JSON in the console with no dependencies

Package Exports

  • color-json

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (color-json) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Color JSON in the console with no dependencies

screenshot

Usage

Default Usage

const cj = require('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

const customColors = {
  separator: 'yellow',
  string: 'yellow',
  number: 'blue',
  boolean: 'magenta',
  null: 'red',
  key: 'green'
};
console.log(cj(topPlanets, customColors));

Customize Colors

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

console.log(cj(topPlanets, undefined, undefined, 4));

Color Tool

hex to console color

Credits

user123444555621 for the syntax highlight regular expressions