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

jsoncrack-react

v1.0.3

Published

Reusable JSON Crack canvas as a React component

Downloads

3,250

Readme

jsoncrack-react

Reusable JSON graph canvas component from JSON Crack — visualize JSON as interactive node graphs.

  • React component API
  • Interactive canvas (pan/zoom + optional controls)
  • TypeScript types included

Live demo · GitHub · npm

Install

npm install jsoncrack-react

Peer dependencies: react >= 18, react-dom >= 18

Setup

Import the stylesheet once in your app entry point:

import "jsoncrack-react/style.css";

Quick Start

import { JSONCrack } from "jsoncrack-react";

export function Example() {
  return (
    <div style={{ height: 700 }}>
      <JSONCrack
        json={{
          user: {
            id: 1,
            name: "Ada",
            tags: ["admin", "staff"],
          },
        }}
      />
    </div>
  );
}

The wrapper must have an explicit height.

Props

| Prop | Type | Default | Description | | --- | --- | --- | --- | | json | string \| object \| unknown[] | - | JSON input data to visualize | | theme | "dark" \| "light" | "dark" | Canvas theme | | layoutDirection | "LEFT" \| "RIGHT" \| "DOWN" \| "UP" | "RIGHT" | Layout direction | | showControls | boolean | true | Show built-in camera controls | | showGrid | boolean | true | Show grid background | | trackpadZoom | boolean | false | Enables two-finger trackpad gesture zoom behavior | | centerOnLayout | boolean | true | Auto-center on first/major layout changes | | maxRenderableNodes | number | 1500 | Node rendering safety limit | | className | string | - | Wrapper class | | style | React.CSSProperties | - | Wrapper inline style | | onNodeClick | (node: NodeData) => void | - | Node click callback | | onParse | (graph: GraphData) => void | - | Parsed graph callback | | onParseError | (error: Error) => void | - | Parse error callback | | onViewportCreate | (viewPort: ViewPort) => void | - | Viewport ready callback | | renderNodeLimitExceeded | (nodeCount: number, maxRenderableNodes: number) => React.ReactNode | - | Custom fallback when node limit is exceeded |

Performance

The component renders all nodes as SVG elements. For large inputs, rendering cost grows with the number of nodes.

  • Default limit: maxRenderableNodes is set to 1500. Graphs exceeding this render a fallback instead of the canvas.
  • Recommended range: Up to ~300–500 nodes for smooth interaction. Beyond that, panning and zooming may feel sluggish depending on the device.
  • Reduce node count: Flatten or trim your data before passing it in. Arrays of primitives become individual nodes, so large arrays expand the graph quickly.
  • Custom fallback: Use renderNodeLimitExceeded to show a message or alternative UI when the limit is hit.
<JSONCrack
  json={data}
  maxRenderableNodes={300}
  renderNodeLimitExceeded={(count, max) => (
    <p>Too large to render ({count} nodes, limit is {max})</p>
  )}
/>

Imperative API (ref)

import { useRef } from "react";
import { JSONCrack, type JSONCrackRef } from "jsoncrack-react";

export function WithRef({ json }: { json: string }) {
  const ref = useRef<JSONCrackRef>(null);

  return (
    <>
      <button onClick={() => ref.current?.centerView()}>Center</button>
      <button onClick={() => ref.current?.zoomIn()}>+</button>
      <button onClick={() => ref.current?.zoomOut()}>-</button>
      <div style={{ height: 600 }}>
        <JSONCrack ref={ref} json={json} />
      </div>
    </>
  );
}

JSONCrackRef methods:

  • zoomIn()
  • zoomOut()
  • setZoom(zoomFactor: number)
  • centerView()
  • focusFirstNode()

Utility: parseGraph

If you only need parser output:

import { parseGraph } from "jsoncrack-react";

const result = parseGraph('{"a":[1,2,3]}');
// result: { nodes, edges, errors }

Exported Types

  • JSONCrackProps
  • JSONCrackRef
  • ParseGraphResult
  • CanvasThemeMode
  • LayoutDirection
  • NodeData
  • EdgeData
  • GraphData
  • NodeRow

License

Apache-2.0