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

@zerodevx/svelte-json-view

v2.0.0

Published

View JSON data prettily

Readme

NPM Version NPM Downloads

svelte-json-view

View JSON data prettily.

A lightweight, expandable, tree-like JSON viewer. Use it as a Svelte component or drop it into any Vanilla JS app.

Here's a demo.

Install

npm i @zerodevx/svelte-json-view

Usage

Svelte

If you're using this in a Svelte app:

<!-- Component.svelte -->
<script>
  import { JsonView } from '@zerodevx/svelte-json-view'

  let json = $state({ foo: 'bar' })
</script>

<JsonView {json} />

[!WARNING]
Requires Svelte 5+ (runes mode). For compatibility with Svelte 4 or earlier, please use v1.x.

Vanilla JS

For other projects with a bundler:

// Import the bundled code
import { createJsonView } from '@zerodevx/svelte-json-view/bundled.js'

const app = createJsonView({
  target: document.querySelector('#target'), // node to render into
  json: { foo: 'bar' } // json data to view
})

app.update({ foo: 'baz' }) // update the data

app.destroy() // remove from DOM

Or load via CDN:

<head>
  <script type="module">
    import { createJsonView } from 'https://cdn.jsdelivr.net/npm/@zerodevx/svelte-json-view@2'
    const app = createJsonView({ target: document.querySelector('#target'), json: { foo: 'bar' } })
  </script>
</head>
<body>
  <div id="target"></div>
</body>

Theming

In general, use CSS variables.

| Name | Default | Description | | ------------------------------ | -------------- | ----------------------------------------- | | --jsonPaddingLeft | 1rem | Left padding applied at each depth | | --jsonBorderLeft | 1px dotted | Left border style applied at each depth | | --jsonBracketColor | currentcolor | Colour for brackets [, {, } and ] | | --jsonBracketHoverBackground | #e5e7eb | Bracket hover background | | --jsonSeparatorColor | currentcolor | Colour for separators : and , | | --jsonKeyColor | currentcolor | Colour for keys | | --jsonValColor | #9ca3af | Default colour for values | | --jsonValStringColor | #059669 | Colour for string values | | --jsonValNumberColor | #d97706 | Colour for number values | | --jsonValBooleanColor | #2563eb | Colour for boolean values |

For a custom font (monospace recommended) or CSS var overrides, try wrapping the component and scope the styles to the wrapper:

<div class="wrap">
  <JsonView {json} />
</div>

<style>
  .wrap {
    font-family: monospace;
    font-size: 14px;
    --jsonBorderLeft: 2px dashed red;
    --jsonValColor: blue;
    ...
  }
</style>

Props

| Name | Type | Default | Description | | ------- | -------- | ----------- | -------------------------------- | | json | object | undefined | Un-stringified object to display | | depth | number | Infinity | Initial expansion depth |

Development

Setup

Clone the repository and install dependencies:

git clone https://github.com/zerodevx/svelte-json-view.git
cd svelte-json-view
npm i

Run the Dev Server

Start the Vite development server:

npm run dev

Open http://localhost:5173 in your browser to view the test page. The library source files are located in src/lib/.

Run Tests

End-to-end tests run on Playwright:

npm test

Test specifications in src/routes/.

Build the Package

Packaging via SvelteKit:

npm run build

Contributing

Bugs and Feature Requests

Please open a new issue or discussion on GitHub to request features or report bugs.

Pull Requests

Standard GitHub contribution workflow applies. Please ensure all tests pass before submitting a pull request.

Changelog

See the releases page.

License

ISC