npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

json-custom-element

v1.0.7

Published

HTML custom element that allows you to render JSON objects in HTML documents with basic editing capabilities, in pure HTML, CSS and JS without any dependencies

Downloads

86

Readme

MIT License NPM Version NPM Version

<json-custom> JSON viewer/editor Custom HTML Element

<json-custom> is an HTML custom element that allows you to render JSON objects in HTML documents with human-readable formatting and expandable interaction for browsing deep JSON structures, edit values and sort arrays.

It uses only plain HTML/CSS/JS with no dependencies.

It was originally based on mohsen1's pretty-json custom viewer element.

Installation

npm install json-custom-element

Usage

CDN

<script type="module" src="https://unpkg.com/json-custom-element/JSONCustomElement.min.js"></script>

NPM

import 'json-custom-element';

Example

<json-custom>
{
  "hello": "world",
  "value": 42,
  "enabled": true,
  "extra": null,
  "nested": { "key": "value", "array": [0, 1 ,2 ,"a"] }
}
</json-custom>

Your JSON will be rendered as a human-readable format:

Features

  • HTML Custom Element without any dependencies, works in any modern browser
  • No need to install any dependencies or build tools, just drop the script in your HTML and start using it
  • Display large JSON objects with expandable and collapsible sections
  • Supports truncating very large strings and arrays with an ellipsis
  • Allows some customization using CSS variables
  • All JSON intrinsic formating symbols (quotes, colon, comma) are delegated to HTML pseudo elements ::before/after and CSS managed
  • Show element count on arrays if requested
  • Edit values and sort array elements
  • Updates textContent property and emits an InputEvent when edited

To-do List

  • [X] Edit boolean values
  • [X] Hide (index) keys for array of objects
  • [ ] Add/Delete keys

Attributes

You can customize the rendering of the JSON object by setting the following attributes on the <json-custom> element:

array-size

Show element count on arrays

<json-custom array-size>{a: [0, 1, 2, "foo"]}</json-custom>

rw

By default, the JSON object is only a viewer, set the rw attribute (to "" or "true") to allow modification:

<json-custom rw>{"hello": {"world": "!"}}</json-custom>

expand

By default, the JSON object is rendered expanded up to 1 level deep (expand="1"). You can set the expand attribute to a number to expand the JSON object up to that level deep:

<json-custom expand="2">{"hello": {"world": "!"}}</json-custom>

Collapsed by default

You can set the expand attribute to 0 to render the JSON object collapsed by default:

<json-custom expand="0">{"hello": {"world": "!"}}</json-custom>

truncate-string

By default, strings longer than 500 characters are truncated with an ellipsis. You can set the truncate-string attribute to a number to truncate strings longer than that number of characters:

<json-custom truncate-string="10">
  {"hello": "long string that will be truncated"}
</json-custom>

Customization

You can customize the appearance of the rendered JSON using CSS variables:

json-custom {
  --symbol-color: #737373;
  --string-color: #009900;
  --number-color: #0000ff;
  --null-color: #666666;
  --boolean-true-color: #d23c91;
  --boolean-false-color: #d23c91;
  --indent: 2rem;
  --font-family: monospace;
  --font-size: 1rem;
}

/* Also handle the dark mode */
@media (prefers-color-scheme: dark) {
  json-custom {
    --symbol-color: #6c6c6c;
    --string-color: #21c521;
    --number-color: #0078b3;
    --null-color: #8c8888;
    --boolean-true-color: #c737b3;
    --boolean-false-color: #c737b3;
    --indent: 2rem;
    --font-family: monospace;
    --font-size: 1rem;
  }
}