
Security News
New CVE Forecasting Tool Predicts 47,000 Disclosures in 2025
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.
@pinojs/json-colorizer
Advanced tools
A library to format JSON with colors for display in the console
A library for colorizing JSON strings
This package is a simple console syntax highlighter for JSON.
npm install --save @pinojs/json-colorizer
const colorize = require('@pinojs/json-colorizer')
console.log(colorize({ foo: 'bar' }))
If you pass a string to the colorize function, it will treat it as pre-serialized JSON. This can be used in order to colorize pretty-printed JSON:
const colorize = require('@pinojs/json-colorizer')
const json = JSON.stringify({ foo: 'bar' }, null, 2)
console.log(colorize(json))
To pretty-print the resulting JSON, pass the pretty: true
option to the options object:
const colorize = require('@pinojs/json-colorizer')
const json = '{"foo": "bar"}'
console.log(colorize(json, { pretty: true }))
You can specify a color to use for coloring individual tokens by providing a colors
object in the options object. This should map token types to the names of color functions (see the colorette styles reference).
A color can also be specified as a hex value starting with the #
symbol.
const colorize = require('@pinojs/json-colorizer')
console.log(
colorize(
{ foo: 'bar' },
{
colors: {
STRING_KEY: 'green',
STRING_LITERAL: 'magentaBright',
NUMBER_LITERAL: 'blue'
}
}
)
)
The tokens available are:
BRACE
BRACKET
COLON
COMMA
STRING_KEY
STRING_LITERAL
NUMBER_LITERAL
BOOLEAN_LITERAL
NULL_LITERAL
FAQs
A library to format JSON with colors for display in the console
The npm package @pinojs/json-colorizer receives a total of 2,862 weekly downloads. As such, @pinojs/json-colorizer popularity was classified as popular.
We found that @pinojs/json-colorizer demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
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.
Security News
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.