react-json-treeview

Author2026
Published
ReactTypeScript

At some point I realized I had written some version of a JSON tree viewer in multiple projects. Nexxus needed one for inspecting config backup diffs from Unimus -- large, nested payloads where operators needed to find specific keys and compare values. Other projects had similar needs: inspecting API responses, debugging state snapshots, reviewing structured config. Each time, I'd reach for an existing library, find it either too bare or too heavy, and end up writing something custom.

The pattern was obvious. Instead of implementing the same thing slightly differently every time, I extracted it into a proper package once and used it everywhere.

What it does

@luismvl/react-json-treeview is a zero-dependency React component for inspecting JSON data. React is the only peer dependency -- nothing else in the bundle.

Core features

  • Search with next/previous match navigation -- essential for large payloads
  • Sticky breadcrumb that tracks scroll position, showing where you are in deeply nested structures
  • Keyboard navigation for traversing nodes without a mouse
  • Imperative ref API -- expand, collapse, scrollToPath, searchNext, searchPrev for programmatic control from the parent component
  • Syntax highlighting for strings, numbers, booleans, null
  • Theming -- light, dark, and auto modes via CSS variables

Configuration

Everything is configurable: defaultExpanded, searchable, showBreadcrumb, indentSize, fontSize. Callbacks for node clicks and search state changes let the parent application react to user interactions.

Design constraints

The zero-dependency rule was deliberate from the start. No version conflicts, small bundle, and nothing unexpected in the consumer's dependency tree. TypeScript-first with full type definitions shipped in the package.

Compatible with React 18 and 19. Published on npm as @luismvl/react-json-treeview with a live playground on GitHub Pages.