Socket
Socket
Sign inDemoInstall

json-pretty-html

Package Overview
Dependencies
0
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    json-pretty-html

Transforms a JSON object to a pretty piece of HTML Edit


Version published
Weekly downloads
1.4K
increased by19.29%
Maintainers
1
Install size
21.5 kB
Created
Weekly downloads
 

Readme

Source

Build Status Dependencies NPM Downloads MIT Node.js version

json-pretty-html

Transforms a JSON object into an HTML string. Allows selecting a subset of the object and highlight it with a CSS class.

Usage

var json = {
  "id": 2,
  "name": "An ice sculpture",
  "price": 12.50,
  "tags": ["cold", "ice"],
  "dimensions": {
    "length": 7.0,
    "width": 12.0,
    "height": 9.5
  },
  "warehouseLocation": {
    "latitude": -78.75,
    "longitude": 20.4
  }
};
var prettyHtml = require('json-pretty-html').default;
var html = prettyHtml(json, json.dimensions);

With a nice CSS, the result will be:

Result

CSS

You can use the default 'darcula' like stylesheet.

Or you can define your own styles. See below the list of CSS classes used in the generated HTML:

CSS ClassPurpose
json-prettyA div grouping several lines, delimited by the start/end of the object or the start/end of the selection
json-selectedThe current selection div, if any. Always associated with the json-pretty class.
json-keyObject key, excluding double quotes
json-stringString value, excluding double quotes
json-numberNumber value
json-booleanBoolean value

Keywords

FAQs

Last updated on 26 Dec 2018

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc