react-json-view vs react-json-tree vs jsoneditor vs react-json-editor-ajrm vs react-jsonschema-form vs jsoneditor-react
JSON Editing and Visualization Libraries Comparison
1 Year
react-json-viewreact-json-treejsoneditorreact-json-editor-ajrmreact-jsonschema-formjsoneditor-reactSimilar Packages:
What's JSON Editing and Visualization Libraries?

JSON editing and visualization libraries in JavaScript provide tools for displaying, editing, and manipulating JSON (JavaScript Object Notation) data in a user-friendly manner. These libraries are particularly useful for applications that require users to interact with structured data, such as configuration files, form data, or API responses. They often include features like tree views, inline editing, validation, and support for complex data types, making it easier for users to understand and modify JSON data. Examples include jsoneditor, react-json-view, and react-jsonschema-form, each offering unique functionalities tailored to different use cases.

Package Weekly Downloads Trend
Github Stars Ranking
Stat Detail
Package
Downloads
Stars
Size
Issues
Publish
License
react-json-view667,2153,565-1814 years agoMIT
react-json-tree428,00514,17863.2 kB2072 months agoMIT
jsoneditor168,97511,8828.09 MB230a month agoApache-2.0
react-json-editor-ajrm57,266359350 kB12 years agoMIT
react-jsonschema-form32,01514,816-3005 years agoApache-2.0
jsoneditor-react18,30327365 kB43-MIT
Feature Comparison: react-json-view vs react-json-tree vs jsoneditor vs react-json-editor-ajrm vs react-jsonschema-form vs jsoneditor-react

Editing Capabilities

  • react-json-view:

    react-json-view offers inline editing capabilities for JSON data, allowing users to edit values directly within the tree structure. It supports collapsible nodes and provides a user-friendly interface for both viewing and editing JSON data, making it more interactive than traditional viewers.

  • react-json-tree:

    react-json-tree is primarily a visualization library and does not support editing JSON data. It excels at displaying data in a tree format, allowing users to explore the structure of JSON objects, but it does not provide any functionality for modifying the data.

  • jsoneditor:

    jsoneditor provides comprehensive editing capabilities, allowing users to edit JSON data both in a tree view and a text editor. It supports inline editing, drag-and-drop for reordering, and even adding or removing nodes, making it highly interactive and flexible.

  • react-json-editor-ajrm:

    react-json-editor-ajrm focuses on providing a simple editing interface with inline editing capabilities. It supports validation and error highlighting, but it is more lightweight and does not offer as many advanced features as jsoneditor, making it easier to use for quick edits.

  • react-jsonschema-form:

    react-jsonschema-form is not an editing tool for JSON data per se, but rather a form generator that creates interactive forms based on JSON Schema definitions. Users can input data through the generated forms, which are then validated and structured according to the schema, facilitating data entry rather than direct editing of JSON.

  • jsoneditor-react:

    jsoneditor-react inherits the full editing capabilities of the jsoneditor library, providing a React-friendly interface for all its features. This includes tree and text editing, inline modifications, and support for complex data structures, ensuring a seamless editing experience in React applications.

Visualization Features

  • react-json-view:

    react-json-view provides a rich visualization of JSON data with collapsible nodes, syntax highlighting, and support for custom styling. It is designed for both viewing and editing, making it versatile for various use cases.

  • react-json-tree:

    react-json-tree specializes in visualizing JSON data in a tree format. It provides customizable styling, collapsible nodes, and the ability to highlight specific parts of the data, making it an excellent choice for detailed visualization.

  • jsoneditor:

    jsoneditor includes visualization features such as a tree view and a text representation of JSON data. It allows users to switch between views, providing a clear understanding of the data structure while editing.

  • react-json-editor-ajrm:

    react-json-editor-ajrm offers basic visualization of JSON data alongside its editing capabilities. It displays the data in a structured format, but its primary focus is on editing rather than advanced visualization.

  • react-jsonschema-form:

    react-jsonschema-form visualizes JSON Schema data by generating forms based on the schema structure. While it does not visualize JSON data directly, it provides a structured way to input and display data according to the defined schema.

  • jsoneditor-react:

    jsoneditor-react provides the same visualization features as jsoneditor, including tree and text views, but optimized for React applications. It allows for smooth integration and rendering of JSON data within React components.

Integration with React

  • react-json-view:

    react-json-view is a React component that displays JSON data with inline editing capabilities. It is designed for easy integration into React applications and supports customization through props, making it flexible for various use cases.

  • react-json-tree:

    react-json-tree is a React component for displaying JSON data in a tree format. It is designed to be easily integrated into React applications and allows for customization through props and styling.

  • jsoneditor:

    jsoneditor is a standalone library that can be integrated into any web application, including those built with React. However, it does not provide React-specific features or optimizations out of the box.

  • react-json-editor-ajrm:

    react-json-editor-ajrm is built for React and provides a simple API for integrating the JSON editor into React applications. It is lightweight and easy to use, making it a good choice for projects that require a straightforward React component.

  • react-jsonschema-form:

    react-jsonschema-form is a React-based library that generates forms from JSON Schema. It is fully integrated with React and provides a declarative way to create forms, handle validation, and manage form state.

  • jsoneditor-react:

    jsoneditor-react is specifically designed for React applications, providing a React wrapper around the jsoneditor library. It handles component lifecycle methods and props, making it easier to use within React projects.

Code Examples

  • react-json-view:

    Basic Usage of react-json-view

    import React from 'react';
    import ReactJson from 'react-json-view';
    
    const data = { name: "John", age: 30, city: "New York" };
    
    const App = () => <ReactJson src={data} theme="monokai" />;
    
    export default App;
    
  • react-json-tree:

    Basic Usage of react-json-tree

    import React from 'react';
    import { JsonTree } from 'react-json-tree';
    
    const data = { name: "John", age: 30, city: "New York" };
    const theme = {
        scheme: 'monokai',
        author: 'Wimer Hazenberg',
        base00: '#272822',
        base01: '#383830',
        base02: '#49483e',
        base03: '#75715e',
        base04: '#f8f8f2',
        base05: '#f8f8f2',
        base06: '#f8f8f2',
        base07: '#f8f8f2',
        base08: '#f92672',
        base09: '#fd971f',
        base0A: '#f4bf75',
        base0B: '#a6e22e',
        base0C: '#a1efe4',
        base0D: '#66d9ef',
        base0E: '#ae81ff',
        base0F: '#cc6633',
    };
    
    const App = () => <JsonTree data={data} theme={theme} />;
    
    export default App;
    
  • jsoneditor:

    Basic Usage of jsoneditor

    <!DOCTYPE html>
    <html>
    <head>
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jsoneditor/9.5.0/jsoneditor.min.css" />
        <script src="https://cdnjs.cloudflare.com/ajax/libs/jsoneditor/9.5.0/jsoneditor.min.js"></script>
        <style>
            #jsoneditor { width: 100%; height: 400px; }
        </style>
    </head>
    <body>
        <div id="jsoneditor"></div>
        <script>
            const container = document.getElementById('jsoneditor');
            const options = { mode: 'tree' };
            const editor = new JSONEditor(container, options);
            const json = { name: "John", age: 30, city: "New York" };
            editor.set(json);
        </script>
    </body>
    </html>
    
  • react-json-editor-ajrm:

    Basic Usage of react-json-editor-ajrm

    import React from 'react';
    import { JsonEditor } from 'react-json-editor-ajrm';
    import locale from 'react-json-editor-ajrm/locale/en';
    
    const App = () => {
        const json = { name: "John", age: 30, city: "New York" };
        return <JsonEditor locale={locale} json={json} />;
    };
    
    export default App;
    
  • react-jsonschema-form:

    Basic Usage of react-jsonschema-form

    import React from 'react';
    import Form from '@rjsf/core';
    
    const schema = {
        title: "A simple form",
        type: "object",
        properties: {
            name: { type: "string", title: "Name", default: "John" },
            age: { type: "integer", title: "Age", default: 30 },
        },
    };
    
    const App = () => <Form schema={schema} />;
    
    export default App;
    
  • jsoneditor-react:

    Basic Usage of jsoneditor-react

    import React from 'react';
    import { JsonEditor } from 'jsoneditor-react';
    import 'jsoneditor-react/es/styles/standalone.css';
    
    const App = () => {
        const json = { name: "John", age: 30, city: "New York" };
        return <JsonEditor json={json} />;
    };
    
    export default App;
    
How to Choose: react-json-view vs react-json-tree vs jsoneditor vs react-json-editor-ajrm vs react-jsonschema-form vs jsoneditor-react
  • react-json-view:

    Choose react-json-view if you need a React component for displaying JSON data with features like collapsible nodes, inline editing, and customizable styling. It is particularly useful for debugging and presenting JSON data in a clear and interactive way, allowing users to explore the data structure easily.

  • react-json-tree:

    Use react-json-tree when you want to display JSON data in a tree format with support for custom styling and interactive features. This library is great for visualizing JSON structures, and it allows for customization of how data is presented, making it suitable for applications that need to highlight specific data or provide a more engaging viewing experience.

  • jsoneditor:

    Choose jsoneditor if you need a versatile, standalone library for both viewing and editing JSON data in a web application. It provides a rich set of features, including a tree view, text editor, and support for complex data types, making it suitable for a wide range of applications.

  • react-json-editor-ajrm:

    Opt for react-json-editor-ajrm if you need a simple and lightweight JSON editor for React applications. It focuses on providing a clean and intuitive interface for editing JSON data, with support for validation and error handling, making it ideal for projects that require a straightforward editing solution without excessive complexity.

  • react-jsonschema-form:

    Select react-jsonschema-form if you are working with JSON Schema and need a library to generate forms dynamically based on schema definitions. This package is ideal for applications that require structured data input, as it automatically handles validation, rendering, and data binding according to the provided JSON Schema.

  • jsoneditor-react:

    Select jsoneditor-react if you are building a React application and want to integrate the jsoneditor library seamlessly. This package provides a React wrapper around jsoneditor, allowing you to leverage its features while maintaining a React-friendly API and lifecycle management.

README for react-json-view

alt text

npm npm Build Status Coverage Status

react-json-view

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

Implementation Example

// import the react-json-view component
import ReactJson from 'react-json-view'

// use the component in your app!
<ReactJson src={my_json_object} />

Output Examples

Default Theme

alt text

Hopscotch Theme, with Triangle Icons:

alt text

Installation Instructions

Install this component with NPM.

npm install --save react-json-view

Or add to your package.json config file:

"dependencies": {
    "react-json-view": "latest"
}

Props

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

Features

  • onEdit, onAdd and onDelete props allow users to edit the src variable
  • Object, array, string and function values can be collapsed and expanded
  • Object and array nodes display length
  • Object and array nodes support a "Copy to Clipboard" feature
  • String values can be truncated after a specified length
  • Arrays can be subgrouped after a specified length
  • Base-16 Theme Support
  • When onEdit is enabled:
    • Ctrl/Cmd+Click Edit Mode
    • Ctrl/Cmd+Enter Submit

Customizing Style

Stock Themes

RJV 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.

Monokai theme example

alt text

Solarized theme example

alt text

Use Your Own Theme

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.

onEdit, onAdd and onDelete Interaction

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.

Contributing to the source code

Run the Dev Server

# clone this repository
git clone git@github.com: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 Production Build

# 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.

Docker Tools

I recommend using docker for development because it enforces environmental consistency.

For information about contributing with Docker, see the README in ./docker.

Inspiration

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.