Skip to content
This repository was archived by the owner on Mar 22, 2026. It is now read-only.

Repository files navigation

$${\color{red}PROJECT}$$$${\color{red}ARCHIVED}$$

jsoneditor-react

VersionLicenceKnown Vulnerabilities

react wrapper implementation for josdejong/jsoneditor

Installation

npm install --save jsoneditor jsoneditor-react

jsoneditor-react using minimalist version of jsoneditor to minimize flat bundle size, so if you want to use Ajv or Ace Editor install them as well

Bundling

Version 3.0.0 and higher provide only es build. Also you need some loaders (in terms of webpack) to load json editor icons and css, e.g.:

module.exports={module: {rules: [{test: /\.css$/,loader: 'css-loader'},{test: /\.svg$/,loader: 'file-loader'}]}};

Usage

import{JsonEditorasEditor}from'jsoneditor-react';import'jsoneditor-react/es/editor.min.css';

later in render method:

render(){return(<Editorvalue={yourJson}onChange={this.handleChange}/>);}

If you want use with Ajv:

importAjvfrom'ajv';constajv=newAjv({allErrors: true,verbose: true});
...
render(){return(<Editorvalue={yourJson}onChange={this.handleChange}ajv={ajv}schema={yourSchema}/>);}

If you want use with Ace Editor:

importacefrom'brace';import'brace/mode/json';import'brace/theme/github';
...
render(){return(<Editorvalue={yourJson}onChange={this.handleChange}ace={ace}theme="ace/theme/github"schema={yourSchema}/>);}

Or:

import'brace';import'brace/mode/json';import'brace/theme/github';
...
render(){return(<Editorvalue={yourJson}onChange={this.handleChange}theme="ace/theme/github"schema={yourSchema}/>);}

Or define your own ace theme

Async component

If you using webpack and es6 dynamic imports you can load jsoneditor-react asynchronously. You can use react-imported-component or your own implementation

importimportedComponentfrom'react-imported-component';constJsonEditor=importedComponent(()=>import(/* webpackChunkName:'jsoneditor' */'jsoneditor-react'));

Or with Ajv and Ace Editor:

constJsonEditor=importedComponent(()=>Promise.all([import(/* webpackChunkName:'jsoneditor' */'jsoneditor-react'),import(/* webpackChunkName:'jsoneditor' */'brace'),import(/* webpackChunkName:'jsoneditor' */'ajv'),import(/* webpackChunkName:'jsoneditor' */'brace/mode/json'),import(/* webpackChunkName:'jsoneditor' */'brace/theme/github')]).then(([{JsonEditor: Editor},ace,Ajv])=>{constajv=newAjv();returnfunctionEditorHoc(props){return(<Editorace={ace}ajv={ajv}theme="ace/theme/github"{...props}/>);}}));

Playground

You can view usage of jsoneditor-react using our storybook.

Steps to run storybook

  • fork or clone repository
  • npm run dev
  • View http://localhost:9001

Right now only one story exporting in storybook: /stories/Editor.jsx, to add more use /.storybook/config.js

Api

Working on docs folder. Right now you can use props declaration

Test

Will be soon!😁

About

react wrapper implementation for https://github.com/josdejong/jsoneditor

Resources

Stars

275 stars

Watchers

5 watching

Forks

Releases

Packages

Used by

Contributors

Languages