All Projects → center-key → Pretty Print Json

center-key / Pretty Print Json

Licence: mit
🦋 Pretty-print JSON data into HTML to indent and colorize (written in TypeScript)

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to Pretty Print Json

Colorjson
Fast Color JSON Marshaller + Pretty Printer for Golang
Stars: ✭ 71 (+73.17%)
Mutual labels:  pretty-print, json, color
Tslog
📝 tslog - Expressive TypeScript Logger for Node.js.
Stars: ✭ 321 (+682.93%)
Mutual labels:  pretty-print, json
Zoya
Truly highly composable logging utility
Stars: ✭ 116 (+182.93%)
Mutual labels:  json, color
Saw
Fast, multi-purpose tool for AWS CloudWatch Logs
Stars: ✭ 1,071 (+2512.2%)
Mutual labels:  json, color
Jsome
✨ Make your JSON look AWESOME
Stars: ✭ 179 (+336.59%)
Mutual labels:  json, color
Prettier Package Json
Prettier formatter for package.json files
Stars: ✭ 86 (+109.76%)
Mutual labels:  pretty-print, json
Leetheme
优雅的主题管理库- 一行代码完成多样式切换
Stars: ✭ 762 (+1758.54%)
Mutual labels:  json, color
Dufy
Color library for Common Lisp
Stars: ✭ 37 (-9.76%)
Mutual labels:  color
Hyperpotamus
🥋 YAML/JSON automation scripting 🤺
Stars: ✭ 38 (-7.32%)
Mutual labels:  json
Jsontableview
Expandable JSON data viewer
Stars: ✭ 37 (-9.76%)
Mutual labels:  json
Brutusin Rpc
Self-describing JSON-RPC web services over HTTP, with automatic API description based on JSON-Schema
Stars: ✭ 36 (-12.2%)
Mutual labels:  json
Redux Json Router
Declarative, Redux-first routing for React/Redux browser applications.
Stars: ✭ 37 (-9.76%)
Mutual labels:  json
Spyne
A transport agnostic sync/async RPC library that focuses on exposing services with a well-defined API using popular protocols.
Stars: ✭ 992 (+2319.51%)
Mutual labels:  json
Java Jq
Lightweight Java wrapper around JQ, a flexible JSON processor available for multiple platforms
Stars: ✭ 37 (-9.76%)
Mutual labels:  json
Flatjson
A fast JSON parser (and builder)
Stars: ✭ 39 (-4.88%)
Mutual labels:  json
Json serializable.dart
Generates utilities to aid in serializing to/from JSON.
Stars: ✭ 979 (+2287.8%)
Mutual labels:  json
Emrichen
A Template engine for YAML & JSON
Stars: ✭ 40 (-2.44%)
Mutual labels:  json
Cfg Center
高性能配置读取服务器,为Yaml配置文件提供JSON RESTful读取接口
Stars: ✭ 39 (-4.88%)
Mutual labels:  json
Jazzon
Add some jazz to your JSON files
Stars: ✭ 38 (-7.32%)
Mutual labels:  json
Contrast Finder
Contrast-Finder finds correct color contrasts (background / foreground) for web accessibility (a11y, WCAG, RGAA). https://app.contrast-finder.org
Stars: ✭ 38 (-7.32%)
Mutual labels:  color

pretty-print-json

logo

Pretty-print JSON data into HTML to indent and colorize (written in TypeScript)

License:MIT npm Size Vulnerabilities Hits Build Build

screenshot

1) Try it out

Interactive online tool to format JSON:
https://pretty-print-json.js.org

2) Setup

Web browser

Load from the jsdelivr.com CDN:

<link rel=stylesheet href=https://cdn.jsdelivr.net/npm/[email protected]/dist/pretty-print-json.css>
...
<script src=https://cdn.jsdelivr.net/npm/[email protected]/dist/pretty-print-json.min.js></script>

For dark mode, replace pretty-print-json.css with pretty-print-json.dark-mode.css in the <link> tag.

Node.js server

Install package for node:

$ npm install pretty-print-json

Import into your application:

import { prettyPrintJson } from 'pretty-print-json';

Or for older CommonJS/UMD environments:

const { prettyPrintJson } = require('pretty-print-json');  //deprecated

3) Usage

API

const html = prettyPrintJson.toHtml(data[, options]);

Example

HTML:
<pre id=account></pre>
JavaScript:

Pass data into prettyPrintJson.toHtml() and display the results.

const data = { active: true, mode: '🚃', codes: [48348, 28923, 39080], city: 'London' };
const elem = document.getElementById('account');
elem.innerHTML = prettyPrintJson.toHtml(data);

Options

Name (key) Type Default Description
indent integer 3 Number of spaces for indentation.
linkUrls boolean true Create anchor tags for URLs.
quoteKeys boolean false Always double quote key names.

4) TypeScript declarations

The TypeScript Declaration File file is pretty-print-json.d.ts in the dist folder.

The output of the prettyPrintJson.toHtml(thing: unknown, options?: FormatOptions) function is configured with a FormatOptions object:

type FormatOptions = {
   indent?:    number,
   linkUrls?:  boolean,
   quoteKeys?: boolean;
   };

Example TypeScript usage with explicit types:

import { prettyPrintJson, FormatOptions } from 'pretty-print-json';

const data = { active: true, mode: '🚃', codes: [48348, 28923, 39080], city: 'London' };
const options: FormatOptions = { linkUrls: true };
const html: string = prettyPrintJson.toHtml(data, options);

5) Contributor notes

To be a contributor, fork the project and run the commands npm install and npm test on your local clone.  Make your edits and rerun the tests.  Pull requests welcome.



Feel free to submit questions at:
github.com/center-key/pretty-print-json/issues

MIT License | Blog post

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].