GithubHelp home page GithubHelp logo

joe-el / pretty-print-json Goto Github PK

View Code? Open in Web Editor NEW

This project forked from center-key/pretty-print-json

0.0 1.0 0.0 111 KB

๐Ÿฆ‹ JavaScript library to pretty-print JSON data to HTML for formatted color display

Home Page: https://pretty-print-json.js.org

License: MIT License

CSS 1.59% JavaScript 59.88% HTML 28.36% Shell 10.17%

pretty-print-json's Introduction

pretty-print-json

logo

JavaScript library to pretty-print JSON data to HTML for formatted color display

License:MIT npm Dependencies Vulnerabilities Hits Build

screenshot

1) Try it out

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

2) Setup

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>

node

Install package from npm:

$ npm install pretty-print-json

Import into your application:

const prettyPrintJson = require('pretty-print-json');

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

Pull requests (PRs) should not update the version number in package.json or any files in the dist folder.ย  The version number and dist files are all updated as part of the release process.

Issues labeled "good first issue" make it easy for first time contributors to participate.ย  Only submit a PR for one of these issues if you're new to this project.



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

MIT License | Blog post

pretty-print-json's People

Contributors

dpilafian avatar pustur avatar alcidesa avatar sowmiyamuthuraman avatar survivorbat avatar lberrymage avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.