All Projects → joeattardi → json-colorizer

joeattardi / json-colorizer

Licence: MIT license
A library for colorizing JSON strings

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to json-colorizer

Better-Less
Cross-compatible syntax highlighting for Less
Stars: ✭ 13 (-83.33%)
Mutual labels:  syntax-highlighting
SubLilyPond
LilyPond syntax highlighting in Sublime Text 2 and 3.
Stars: ✭ 26 (-66.67%)
Mutual labels:  syntax-highlighting
code2tex
Convert source code to a LaTeX document / PDF with syntax highlighting and line numbers.
Stars: ✭ 24 (-69.23%)
Mutual labels:  syntax-highlighting
vscode-ibmi-languages
Syntax highlighting for IBM i languages such as RPG, CL, DDS, MI, and RPGLE fixed/free.
Stars: ✭ 28 (-64.1%)
Mutual labels:  syntax-highlighting
misbehave
Add IDE-like text entry to HTML contenteditable tags
Stars: ✭ 34 (-56.41%)
Mutual labels:  syntax-highlighting
hgrep
Grep with human-friendly search results
Stars: ✭ 335 (+329.49%)
Mutual labels:  syntax-highlighting
h.js
2KB JavaScript Syntax Highlighter
Stars: ✭ 37 (-52.56%)
Mutual labels:  syntax-highlighting
DzNoteEditor
Delphi Property Editor for TStrings supporting formatted languages with syntax highlight
Stars: ✭ 18 (-76.92%)
Mutual labels:  syntax-highlighting
CodeView
Android Library to make it easy to create an Code editor or IDE that support any languages and themes, with auto complete, auto indenting, snippets and more features
Stars: ✭ 254 (+225.64%)
Mutual labels:  syntax-highlighting
sql-heredoc.vim
Syntax highlighting for SQL heredocs.
Stars: ✭ 19 (-75.64%)
Mutual labels:  syntax-highlighting
editor
A text editor written in Nim
Stars: ✭ 24 (-69.23%)
Mutual labels:  syntax-highlighting
intellij-prisma
Prisma schema file support for IntelliJ IDEs (WebStorm, PHPStorm, Pycharm, RubyMine, ...)
Stars: ✭ 25 (-67.95%)
Mutual labels:  syntax-highlighting
myPDDL
PDDL Syntax Highlighting, Snippets, Domain Visualization and more for Sublime Text
Stars: ✭ 32 (-58.97%)
Mutual labels:  syntax-highlighting
Fragaria
Cocoa syntax highlighting text view
Stars: ✭ 53 (-32.05%)
Mutual labels:  syntax-highlighting
sublime-PICO-8
PICO-8 plugin for the Sublime Text 3 editor.
Stars: ✭ 42 (-46.15%)
Mutual labels:  syntax-highlighting
go-highlight
A Go (Golang) code syntax highlighting library.
Stars: ✭ 20 (-74.36%)
Mutual labels:  syntax-highlighting
lammps vscode
VSCODE extension for language support of LAMMPS scripts
Stars: ✭ 26 (-66.67%)
Mutual labels:  syntax-highlighting
highlight
Source code to formatted text converter
Stars: ✭ 44 (-43.59%)
Mutual labels:  syntax-highlighting
clojure.vim
Clojure syntax highlighting for Vim and Neovim.
Stars: ✭ 23 (-70.51%)
Mutual labels:  syntax-highlighting
ansi-to-svg
😹 convert ANSI Escaped CLI strings to SVGs
Stars: ✭ 18 (-76.92%)
Mutual labels:  chalk

json-colorizer

A library for colorizing JSON strings

This package is a simple console syntax highlighter for JSON.

Installation

npm install --save json-colorizer

Usage

const colorize = require('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('json-colorizer');
const json = JSON.stringify({"foo": "bar"}, null, 2);
console.log(colorize(json));

Pretty-printing output

To pretty-print the resulting JSON, pass the pretty: true option to the options object:

const colorize = require('json-colorizer');
const json = '{"foo": "bar"}';
console.log(colorize(json, { pretty: true }));

Specifying colors

NOTE: Prior to version 2.x, the colors were specified by referencing chalk color functions directly. This required requiring chalk into the file. Starting with version 2.x, the colors are specified as a string which is the name (or property path) to the desired color function.

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 chalk styles reference).

A color can also be specified as a hex value starting with the # symbol.

const colorize = require('json-colorizer');
console.log(colorize({ "foo": "bar" }, {
  colors: {
    STRING_KEY: 'green',
    STRING_LITERAL: 'magenta.bold',
    NUMBER_LITERAL: '#FF0000'
  }
}));

The tokens available are:

  • BRACE
  • BRACKET
  • COLON
  • COMMA
  • STRING_KEY
  • STRING_LITERAL
  • NUMBER_LITERAL
  • BOOLEAN_LITERAL
  • NULL_LITERAL
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].