These four libraries address the common need to display or edit JSON data within React applications, but they serve distinct purposes. react-json-view is a versatile, read-only viewer with built-in editing capabilities, ideal for general-purpose inspection. react-json-tree offers a highly customizable, collapsible tree structure, often used for deep debugging sessions. react-json-editor-ajrm is a dedicated two-way binding editor for modifying JSON content directly. In contrast, react-json-pretty is a lightweight, read-only formatter that has seen little maintenance recently and is generally less feature-rich than the others.
When building React applications, you will almost certainly need to display JSON data. Whether it's showing API responses in an admin dashboard, debugging complex state in a developer tool, or allowing users to edit configuration files, the right component makes a huge difference. The ecosystem offers four main contenders: react-json-view, react-json-tree, react-json-editor-ajrm, and react-json-pretty. While they all handle JSON, their architectures and intended use cases differ significantly.
The first decision is simple: do you need to let users edit the JSON, or just view it?
react-json-editor-ajrm is the only package here designed primarily as an editor. It acts like a code editor specifically for JSON. It supports two-way data binding, meaning as the user types, your React state updates automatically. It includes error highlighting if the user types invalid JSON.
import AJRMEditor from 'react-json-editor-ajrm';
function ConfigEditor() {
const [data, setData] = React.useState({ theme: 'dark' });
return (
<AJRMEditor
colors={{ background: '#f5f5f5' }}
data={data}
onChange={(res) => setData(res.jsObject)}
/>
);
}
react-json-view is primarily a viewer, but it includes optional editing features. You can enable editing on specific nodes, allowing users to change values or delete keys without rewriting the whole structure. It strikes a balance between inspection and modification.
import ReactJson from 'react-json-view';
function DataInspector() {
const [data, setData] = React.useState({ id: 1 });
return (
<ReactJson
src={data}
onEdit={(edit) => setData(edit.updated_src)}
enableClipboard={true}
/>
);
}
react-json-tree and react-json-pretty are strictly read-only. They are designed to render data for inspection. react-json-tree focuses on deep exploration with collapsible nodes, while react-json-pretty simply formats the text.
// react-json-tree: Read-only inspection
import { JSONTree } from 'react-json-tree';
<JSONTree data={{ status: 'ok' }} theme='monokai' />
// react-json-pretty: Simple formatting
import JSONPretty from 'react-json-pretty';
<JSONPretty id="json-pretty" data="{\"status\":\"ok\"}"></JSONPretty>
For large datasets, the ability to collapse and expand branches is critical.
react-json-tree shines here. It was built specifically to mimic the browser console's object inspector. It handles deep nesting efficiently and allows you to customize how every single node renders. You can expand all nodes by default or keep them collapsed.
import { JSONTree } from 'react-json-tree';
// Fully expanded tree for deep debugging
<JSONTree
data={largeObject}
shouldExpandNodeInitially={() => true}
/>
react-json-view also supports collapsing, but it is more opinionated. It provides a clean UI with toggle arrows next to objects and arrays. It is less customizable than react-json-tree but works perfectly for most standard dashboards without extra configuration.
import ReactJson from 'react-json-view';
// Default collapsible behavior
<ReactJson src={largeObject} collapsed={1} /> // Collapse after 1 level
react-json-pretty does not support collapsing. It renders the entire JSON structure as formatted text. If you pass a massive object, it will render all of it at once, which can hurt performance and readability.
// No collapsing available
<JSONPretty data={largeObject} />
react-json-editor-ajrm handles structure visually but focuses on editing. It does not offer the same "tree explorer" feel as the others; instead, it presents the data as an editable document.
How much control do you need over the look and feel?
react-json-tree offers the deepest customization. You can pass a custom theme object or even override specific value renderers. If you need to display a date object differently than a string, this is the tool for you.
import { JSONTree } from 'react-json-tree';
const customTheme = {
scheme: 'custom',
base00: '#ffffff',
base0D: '#0000ff' // Change key color
};
<JSONTree data={data} theme={customTheme} />
react-json-view provides a solid set of pre-built themes (like 'monokai', 'github', 'rjv-default') and allows you to tweak colors via props. It is easier to set up than react-json-tree but less flexible for extreme custom cases.
import ReactJson from 'react-json-view';
<ReactJson src={data} theme="github" iconStyle="circle" />
react-json-editor-ajrm allows color customization for the editor background and syntax elements, but its primary goal is functional editing, not visual theming.
import AJRMEditor from 'react-json-editor-ajrm';
<AJRMEditor
data={data}
colors={{ background: '#2d2d2d', string: '#a5d6ff' }}
/>
react-json-pretty has minimal theming options. You mostly rely on CSS to style the container, as the component itself outputs standard HTML spans with limited hooks for deep styling.
This is a critical factor for architectural decisions.
react-json-pretty has not seen significant updates in years. It is effectively in maintenance mode. While it still works for basic tasks, relying on it for new projects carries risk if you encounter bugs or need modern React features (like strict mode compliance). It is generally recommended to avoid this package for new enterprise applications.
react-json-editor-ajrm, react-json-view, and react-json-tree are actively maintained and widely used in the community. They support modern React versions and have fewer known breaking changes.
You are building an admin panel where support agents need to inspect user data payloads and copy specific values.
react-json-view<ReactJson
src={userData}
name="User Profile"
collapsed={2}
enableClipboard={(copy) => notify('Copied!')}
/>
Your app allows users to upload and edit complex JSON configuration files for integrations.
react-json-editor-ajrm<AJRMEditor
data={configData}
placeholder="Paste JSON here"
onChange={(res) => {
if (!res.error) saveConfig(res.jsObject);
}}
/>
You are building a custom Redux or Zustand debugger tool to visualize deeply nested application state.
react-json-tree<JSONTree
data={appState}
valueRenderer={(valueAsString, value) => <strong>{valueAsString}</strong>}
/>
| Feature | react-json-view | react-json-tree | react-json-editor-ajrm | react-json-pretty |
|---|---|---|---|---|
| Primary Use | View & Light Edit | Deep Inspection | Heavy Editing | Simple View |
| Collapsible | β Yes | β Yes (Advanced) | β No (Editor style) | β No |
| Two-Way Binding | β Optional | β No | β Yes (Core feature) | β No |
| Customization | Medium | High | Medium | Low |
| Maintenance | β Active | β Active | β Active | β οΈ Stale |
| Bundle Weight | Moderate | Moderate | Higher | Low |
For most modern React applications, react-json-view is the safest default choice. It handles 90% of use cases where you need to display JSON nicely with optional copy/edit features.
If you are building a configuration tool where users must write JSON, switch to react-json-editor-ajrm. If you are building a developer tool or debugger requiring deep customization of the tree view, choose react-json-tree.
Avoid react-json-pretty unless you have a very specific constraint requiring its minimal footprint and can accept the lack of active maintenance. In professional environments, the slight bundle savings are rarely worth the potential technical debt of an unmaintained dependency.
Choose react-json-view for the most balanced solution that handles both viewing and light editing out of the box. It is the industry standard for dashboards, admin panels, and developer tools where users need to inspect data, copy values, and occasionally tweak properties without needing a full-code editor experience.
Choose react-json-tree if you need a highly customizable, collapsible tree view primarily for debugging or inspecting complex state objects. It excels when you need to render custom components for specific data types or require fine-grained control over the theme and node behavior, but it is less suited for direct user editing compared to other options.
Avoid choosing react-json-pretty for new production projects. While it offers a simple, lightweight way to display formatted JSON, it lacks active maintenance and modern features like collapsible nodes or editing. Only consider it for extremely simple, read-only displays where bundle size is the absolute highest priority and no interactivity is needed.
Choose react-json-editor-ajrm when your primary requirement is a dedicated input field for users to create or modify JSON data. It provides two-way binding, syntax highlighting, and real-time validation, making it perfect for configuration forms or API payload builders where the user needs to type and edit raw JSON safely.
![]()
RJV is a React component for displaying and editing javascript arrays and JSON objects.
This component provides a responsive interface for displaying arrays or JSON in a web browser. NPM offers a distribution of the source that's transpiled to ES5; so you can include this component with any web-based javascript application.
Check out the Interactive Demo
// import the react-json-view component
import ReactJson from 'react-json-view'
// use the component in your app!
<ReactJson src={my_json_object} />


Install this component with NPM.
npm install --save react-json-view
Or add to your package.json config file:
"dependencies": {
"react-json-view": "latest"
}
| Name | Type | Default | Description |
|---|---|---|---|
src | JSON Object | None | This property contains your input JSON |
name | string or false | "root" | Contains the name of your root node. Use null or false for no name. |
theme | string | "rjv-default" | RJV supports base-16 themes. Check out the list of supported themes in the demo. A custom "rjv-default" theme applies by default. |
style | object | {} | Style attributes for react-json-view container. Explicit style attributes will override attributes provided by a theme. |
iconStyle | string | "circle" | Style of expand/collapse icons. Accepted values are "circle", triangle" or "square". |
indentWidth | integer | 4 | Set the indent-width for nested objects |
collapsed | boolean or integer | false | When set to true, all nodes will be collapsed by default. Use an integer value to collapse at a particular depth. |
collapseStringsAfterLength | integer | false | When an integer value is assigned, strings will be cut off at that length. Collapsed strings are followed by an ellipsis. String content can be expanded and collapsed by clicking on the string value. |
shouldCollapse | (field)=>{} | false | Callback function to provide control over what objects and arrays should be collapsed by default. An object is passed to the callback containing name, src, type ("array" or "object") and namespace. |
groupArraysAfterLength | integer | 100 | When an integer value is assigned, arrays will be displayed in groups by count of the value. Groups are displayed with bracket notation and can be expanded and collapsed by clicking on the brackets. |
enableClipboard | boolean or (copy)=>{} | true | When prop is not false, the user can copy objects and arrays to clipboard by clicking on the clipboard icon. Copy callbacks are supported. |
displayObjectSize | boolean | true | When set to true, objects and arrays are labeled with size |
displayDataTypes | boolean | true | When set to true, data type labels prefix values |
onEdit | (edit)=>{} | false | When a callback function is passed in, edit functionality is enabled. The callback is invoked before edits are completed. Returning false from onEdit will prevent the change from being made. see: onEdit docs |
onAdd | (add)=>{} | false | When a callback function is passed in, add functionality is enabled. The callback is invoked before additions are completed. Returning false from onAdd will prevent the change from being made. see: onAdd docs |
defaultValue | string |number |boolean |array |object | null | Sets the default value to be used when adding an item to json |
onDelete | (delete)=>{} | false | When a callback function is passed in, delete functionality is enabled. The callback is invoked before deletions are completed. Returning false from onDelete will prevent the change from being made. see: onDelete docs |
onSelect | (select)=>{} | false | When a function is passed in, clicking a value triggers the onSelect method to be called. |
sortKeys | boolean | false | set to true to sort object keys |
quotesOnKeys | boolean | true | set to false to remove quotes from keys (eg. "name": vs. name:) |
validationMessage | string | "Validation Error" | Custom message for validation failures to onEdit, onAdd, or onDelete callbacks |
displayArrayKey | boolean | true | When set to true, the index of the elements prefix values |
onEdit, onAdd and onDelete props allow users to edit the src variableonEdit is enabled:
Ctrl/Cmd+Click Edit ModeCtrl/Cmd+Enter SubmitRJV now supports base-16 themes!
You can specify a theme name or object when you instantiate your rjv component.
<ReactJson src={my_important_json} theme="monokai" />
Check out the list of supported themes in the component demo.


You can supply your own base-16 theme object.
To better understand custom themes, take a look at my example implementation and the base-16 theme styling guidelines.
Pass callback methods to onEdit, onAdd and onDelete props. Your method will be invoked when a user attempts to update your src object.
The following object will be passed to your method:
{
updated_src: src, //new src value
name: name, //new var name
namespace: namespace, //list, namespace indicating var location
new_value: new_value, //new variable value
existing_value: existing_value, //existing variable value
}
Returning false from a callback method will prevent the src from being affected.
# clone this repository
git clone [email protected]:mac-s-g/react-json-view.git && cd react-json-view
# install dependencies
npm install --save-dev
# run the dev server with hot reloading
npm run dev
Webpack Dev Server should automatically open up http://localhost:2000 in your web browser. If it does not, open a browser and navigate to port 2000. The hot reloader will automatically reload when files are modified in the /src/ directory.
# run the build (note: you may need to use `sudo` priveledges to run the build successfully)
npm run build
Please add tests for your code before posting a pull request.
You can run the test suite with npm run test or npm run test:watch to automatically reload when files are modified.
I recommend using docker for development because it enforces environmental consistency.
For information about contributing with Docker, see the README in ./docker.
I drew a ton of design ideas from react-json-tree. Thanks to the RJT contributors for putting together an awesome component!
I'm also inspired by users who come up with interesting feature requests. Reach out to me with ideas for this project or other projects you want to collaborate on. My email address is listed on my github user page.