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

modern-json-react

v1.1.1

Published

A production-grade, fully-featured JSON editor React component with tree view, code editing, JSON Schema validation, and accessibility-first design.

Readme

modern-json-react

A production-grade, fully-featured JSON editor React component. Combines code editing, tree view navigation, JSON Schema validation, and accessibility-first design in a single, zero-config package.

Screenshots

Code Mode (Light)

Syntax-highlighted editor with line numbers, bracket matching, and real-time validation:

Code Mode - Light Theme

Tree Mode (Light)

Collapsible tree view with inline editing, type badges, and hover actions:

Tree Mode - Light Theme

Code Mode (Dark)

Full dark theme support with VS Code-inspired color palette:

Code Mode - Dark Theme

Features

  • Dual editing modes — Syntax-highlighted code editor, collapsible tree view, or side-by-side split mode
  • JSON Schema validation — Built-in Draft-07 support with real-time error markers and human-readable messages
  • Tree view editing — Inline value editing, type changing, key renaming, drag-drop reordering, and node deletion
  • Undo / Redo — Full history stack with time-based action grouping and keyboard shortcuts
  • Search — Full-text search across keys and values with regex support and match highlighting
  • Theming — Light and dark presets with 22 CSS custom properties for full customization
  • Formatting — Pretty-print, minify, sort keys (ascending, descending, or custom comparator)
  • Accessibility — WCAG 2.1 AA compliant with full keyboard navigation, ARIA roles, and screen reader announcements
  • TypeScript — Complete type definitions with JSDoc comments
  • Zero peer dependencies — Only requires React 18+

Installation

npm install modern-json-react

Quick Start

import { JsonEditor } from 'modern-json-react';

function App() {
  const [data, setData] = useState({ name: "John", age: 30 });

  return (
    <JsonEditor
      value={data}
      onChange={(value) => setData(value)}
      height={500}
    />
  );
}

Props

| Prop | Type | Default | Description | |------|------|---------|-------------| | value | unknown | — | JSON value (object, array, string, etc.) or raw JSON string | | onChange | (value, rawText) => void | — | Called when the JSON value changes | | mode | 'code' \| 'tree' \| 'split' | 'code' | Active editing mode | | onModeChange | (mode) => void | — | Called when the user switches modes | | schema | JSONSchema | — | JSON Schema for validation (Draft-07, 2019-09, 2020-12) | | validators | CustomValidator[] | — | Custom validation functions | | validationMode | 'onChange' \| 'onBlur' \| 'onSubmit' \| 'manual' | 'onChange' | When to trigger validation | | onValidate | (errors) => void | — | Called when validation completes | | theme | 'light' \| 'dark' \| 'auto' \| ThemeConfig | 'light' | Theme preset or custom config | | height | string \| number | 400 | Editor height (CSS value or pixels) | | readOnly | boolean | false | Disable editing | | searchable | boolean | true | Show search bar | | sortable | boolean | true | Enable key sorting | | indentation | 2 \| 4 \| 'tab' | 2 | Indentation style | | lineNumbers | boolean | true | Show line numbers in code mode | | className | string | — | Additional CSS class |

Schema Validation

Pass a JSON Schema to get real-time validation with inline error markers:

const schema = {
  type: 'object',
  properties: {
    name: { type: 'string', minLength: 1 },
    age: { type: 'number', minimum: 0 },
    email: { type: 'string', format: 'email' },
  },
  required: ['name', 'email'],
};

<JsonEditor
  value={data}
  onChange={setData}
  schema={schema}
  onValidate={(errors) => console.log(errors)}
/>

Custom Validators

Add your own validation rules alongside schema validation:

const noEmptyArrays = (value, path) => {
  if (Array.isArray(value) && value.length === 0) {
    return [{ message: 'Array must not be empty', path, severity: 'warning' }];
  }
  return [];
};

<JsonEditor value={data} validators={[noEmptyArrays]} />

Theming

Use a preset or provide a full custom theme:

// Preset
<JsonEditor theme="dark" />

// Auto (follows OS preference)
<JsonEditor theme="auto" />

// Custom theme
<JsonEditor theme={{
  name: 'ocean',
  bg: '#0d1b2a',
  fg: '#e0e1dd',
  border: '#1b263b',
  keyColor: '#48cae4',
  stringColor: '#90e0ef',
  numberColor: '#ade8f4',
  // ... see ThemeConfig for all 22 properties
}} />

Override individual tokens with CSS custom properties:

.my-editor {
  --mjr-bg: #fafafa;
  --mjr-key: #d63384;
  --mjr-string: #198754;
}

Exported Utilities

The package also exports core utilities for advanced use cases:

import {
  // Parsing
  parseJson, stringifyJson, isValidJson,

  // Validation
  validateSchema, runCustomValidators,

  // Formatting
  formatJson, minifyJson, sortJsonKeys, computeStats,

  // Path operations (immutable)
  getByPath, setByPath, deleteByPath, parsePath,

  // Hooks (for building custom editors)
  useJsonParser, useUndoRedo, useSearch,

  // Themes
  lightTheme, darkTheme,
} from 'modern-json-react';

Keyboard Shortcuts

| Shortcut | Action | |----------|--------| | Ctrl/Cmd + Z | Undo | | Ctrl/Cmd + Shift + Z | Redo | | Ctrl/Cmd + F | Open search | | Escape | Close search | | Tab | Indent (code mode) | | Enter | Edit selected node (tree mode) | | Delete | Delete selected node (tree mode) | | Arrow keys | Navigate tree nodes |

Browser Support

Chrome/Edge 90+, Firefox 90+, Safari 15+. Requires React 18 or later.

Development

# Install dependencies
npm install

# Run tests
npm test

# Type checking
npm run typecheck

# Build for production
npm run build

# Open interactive demo
open demo/index.html

Project Structure

src/
├── index.ts                 # Public API exports
├── JsonEditor.tsx           # Root component
├── components/
│   ├── CodeEditor/          # Syntax-highlighted text editor
│   ├── TreeEditor/          # Collapsible tree with inline editing
│   ├── Toolbar/             # Mode switcher, search, actions
│   └── StatusBar/           # Validation status, cursor position, stats
├── hooks/
│   ├── useJsonParser.ts     # Parse + validate
│   ├── useUndoRedo.ts       # History management
│   └── useSearch.ts         # Search state + matching
├── core/
│   ├── parser.ts            # JSON parsing with error locations
│   ├── validator.ts         # JSON Schema validation engine
│   ├── formatter.ts         # Format, minify, sort, stats
│   └── path.ts              # JSONPath get/set/delete (immutable)
├── themes/                  # Light + dark presets
└── types/                   # TypeScript interfaces

License

MIT