MCPcopy Index your code
hub / github.com/CarlosNZ/json-edit-react

github.com/CarlosNZ/json-edit-react @v1.30.2

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.30.2 ↗ · + Follow
230 symbols 594 edges 104 files 7 documented · 3% 6 cross-repo links
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

json-edit-react

screenshot

A highly-configurable React component for editing or viewing JSON/object data

Explore the Demo

NPM Version GitHub License NPM Downloads

Ask DeepWiki Discuss on GitHub Sponsor

Features include:

  • Easy inline editing of individual values or whole blocks of JSON text
  • 🔒 Granular control – restrict edits, deletions, or additions per element
  • 📏 JSON Schema validation (using 3rd-party validation library)
  • 🎨 Customisable UI — built-in or custom themes, CSS overrides or targeted classes
  • 📦 Self-contained — plain HTML/CSS, no external UI library dependencies, and zero runtime dependencies
  • 🔍 Search & filter — find data by key, value or custom function
  • 🚧 Custom components — replace keys and/or values with specialised components (e.g. date picker, links, images, undefined, BigInt, Symbol)
  • 🌏 Localisation — easily translate UI labels and messages
  • 🔄 Drag-n-drop re-ordering within objects/arrays
  • 🎹 Keyboard customisation — define your own key bindings
  • 🎮 External control via callbacks and triggers

💡 Try the Live Demo to see these features in action!

screenshot


📣️ ANNOUNCEMENT

V2 of json-edit-react is now available in beta, with significant refactors and performance improvements. npm install json-edit-react@beta yarn add json-edit-react@beta pnpm add json-edit-react@beta ❗️ If you're upgrading from V1, be sure to read the migration guide.

📖️ FULL DOCS

If you've got any suggestions, please join the discussion here.


Contents

Installation

# Depending on your package manager:

npm i json-edit-react
# OR
yarn add json-edit-react

Implementation

import { JsonEditor } from 'json-edit-react'

// In your React component:
return (
  <JsonEditor
    data={ jsonData }
    setData={ setJsonData } // optional
    { ...otherProps } />
);

Usage

(for end user)

It's pretty self explanatory (click the "edit" icon to edit, etc.), but there are a few not-so-obvious ways of interacting with the editor:

  • Double-click a value (or a key) to edit it
  • When editing a string, use Cmd/Ctrl/Shift-Enter to add a new line (Enter submits the value)
  • It's the opposite when editing a full object/array node (which you do by clicking "edit" on an object or array value) — Enter for new line, and Cmd/Ctrl/Shift-Enter for submit
  • Escape to cancel editing
  • When clicking the "clipboard" icon, holding down Cmd/Ctrl will copy the path to the selected node rather than its value
  • When opening/closing a node, hold down "Alt/Option" to open/close all child nodes at once
  • For Number inputs, arrow-up and down keys will increment/decrement the value
  • For Boolean inputs, space bar will toggle the value
  • Easily navigate to the next or previous node for editing using the Tab/Shift-Tab keys.
  • Drag and drop items to change the structure or modify display order
  • When editing is not permitted, double-clicking a string value will expand the text to the full value if it is truncated due to length (there is also a clickable "..." for long strings)
  • JSON text input can accept "looser" input, if an additional JSON parsing method is provided (e.g. JSON5). See jsonParse prop.

Have a play with the Demo app to get a feel for it!

Props Reference

The only required property is data (although you will need to provide a setData method to update your data).

This is a reference list of all possible props, divided into related sections. Most of them provide a link to a section below in which the concepts are explored in more detail.

Data Management

Prop Type Default Description
data object\|array none The data to be displayed / edited
setData object\|array => void none Method to update your data object. See Managing state below for additional notes.
onUpdate UpdateFunction none A function to run whenever a value is updated (edit, delete or add) in the editor. See Update functions.
onEdit UpdateFunction none A function to run whenever a value is edited.
onDelete UpdateFunction none A function to run whenever a value is deleted.
onAdd UpdateFunction none A function to run whenever a new property is added.
onChange OnChangeFunction none A function to modify/constrain user input as they type — see OnChange functions.
onError OnErrorFunction none A function to run whenever the component reports an error — see OnErrorFunction.
enableClipboard boolean\|CopyFunction true Enable or disable the "Copy to clipboard" button in the UI. — see Copy Function

Restricting Editing

Prop Type Default Description
restrictEdit boolean\|FilterFunction false If true, no editing at all is permitted. A callback function can be provided — see Advanced Editing Control
restrictDelete boolean\|FilterFunction false As with restrictEdit but for deletion
restrictAdd boolean\|FilterFunction false As with restrictEdit but for adding new properties
restrictTypeSelection boolean\|DataType[]\|TypeFilterFunction false For restricting the data types the user can select, including Custom Node types, and Enums — see Data Type Restrictions
newKeyOptions string[] \| NewKeyOptionsFunction none New keys can be restricted to certain values — see New Key Restrictions & Default Values
defaultValue any\|DefaultValueFilterFunction null Value that new properties are initialised with — see New Key Restrictions & Default Values
restrictDrag boolean\|FilterFunction true Set to false to enable drag and drop functionality — see Drag-n-drop
viewOnly boolean A shorthand if you just want the component to be a viewer, with no editing at all. Overrides any of the above edit restrictions.

Look and Feel / UI

Prop Type Default Description
theme ThemeInput defaultTheme Either one of the built-in themes (imported separately), or an object specifying some or all theme properties — see Themes.
icons {[iconName]: JSX.Element, ... } { } Replace the built-in icons by specifying them here — see Themes.
showIconTooltips boolean false Display icon tooltips when hovering.
indent number 3 Specify the amount of indentation for each level of nesting in the displayed data.
collapse boolean\|number\|FilterFunction false Defines which nodes of the JSON tree will be displayed "opened" in the UI on load — see Collapse.

Extension points exported contracts — how you extend this code

ButtonProps (Interface)
(no doc)
custom-component-library/components/DatePicker/Button.tsx
EditButtonProps (Interface)
(no doc)
src/ButtonPanels.tsx
IconProps (Interface)
(no doc)
src/Icons.tsx
UpdateOptions (Interface)
(no doc)
src/JsonEditor.tsx
CustomNodeData (Interface)
(no doc)
src/CustomNode.ts
KeyDisplayProps (Interface)
(no doc)
src/KeyDisplay.tsx
TextAreaProps (Interface)
(no doc)
src/AutogrowTextArea.tsx
StringDisplayProps (Interface)
(no doc)
src/ValueNodes.tsx

Core symbols most depended-on inside this repo

assign
called by 59
src/utils/assign.ts
extract
called by 47
src/utils/extract.ts
getStyles
called by 46
src/contexts/ThemeProvider.tsx
translate
called by 20
src/localisation.ts
toPathString
called by 18
src/helpers.ts
handleEdit
called by 12
src/JsonEditor.tsx
splitPropertyString
called by 11
src/utils/helpers.ts
updateState
called by 11
demo/src/App.tsx

Shape

Function 175
Interface 55

Languages

TypeScript95%
Python5%

Modules by API surface

src/types.ts19 symbols
src/helpers.ts17 symbols
src/ValueNodes.tsx14 symbols
src/JsonEditor.tsx14 symbols
src/utils/assign.ts12 symbols
src/Icons.tsx10 symbols
demo/src/App.tsx10 symbols
src/contexts/TreeStateProvider.tsx9 symbols
src/contexts/ThemeProvider.tsx8 symbols
src/ValueNodeWrapper.tsx8 symbols
scripts/build_npm_readme.py8 symbols
src/ButtonPanels.tsx7 symbols

For agents

$ claude mcp add json-edit-react \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact