package
A web-based tool to view, edit, format, transform, and validate JSON
npm install vanilla-jsoneditorGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
A web-based tool to view, edit, format, transform, and validate JSON.
Try it out: https://jsoneditoronline.org
This is the vanilla variant of svelte-jsoneditor, which can be used in vanilla JavaScript or frameworks like SolidJS, React, Vue, Angular.

Install using npm:
npm install vanilla-jsoneditorRemark: for usage in a Svelte project, install and use svelte-jsoneditor instead of vanilla-jsoneditor.
If you have a setup for your project with a bundler (like Vite, Rollup, or Webpack), it is best to use the default ES import:
// for use in a React, Vue, or Angular project
import { createJSONEditor } from 'vanilla-jsoneditor'If you want to use the library straight in the browser, use the provided standalone ES bundle:
// for use directly in the browser
import { createJSONEditor } from 'vanilla-jsoneditor/standalone.js'The standalone bundle contains all dependencies of vanilla-jsoneditor, for example lodash-es and Ajv. If you use some of these dependencies in your project too, it means that they will be bundled twice in your web application, leading to a needlessly large application size. In general, it is preferable to use the default import { createJSONEditor } from 'vanilla-jsoneditor' so dependencies can be reused.
<!doctype html>
<html lang="en">
<head>
<title>JSONEditor</title>
</head>
<body>
<div id="jsoneditor"></div>
<script type="module">
import { createJSONEditor } from 'vanilla-jsoneditor/standalone.js'
// Or use it through a CDN (not recommended for use in production):
// import { createJSONEditor } from 'https://unpkg.com/vanilla-jsoneditor/index.js'
// import { createJSONEditor } from 'https://cdn.jsdelivr.net/npm/vanilla-jsoneditor/index.js'
let content =
Depending on whether you are using JavaScript of TypeScript, create either a JSX or TSX file:
//
// JSONEditorReact.tsx
//
import { useEffect, useRef } from 'react'
import { createJSONEditor, JSONEditorPropsOptional } from 'vanilla-jsoneditor'
const JSONEditorReact: React.FC<JSONEditorPropsOptional> = (props) => {
const refContainer = useRef<HTMLDivElement>(null)
const refEditor = useRef<JSONEditor | null>(null)
useEffect(() => {
// create editor
refEditor.current = createJSONEditor({
target: refContainer.current!,
props: {}
//
// JSONEditorReact.jsx
//
import { useEffect, useRef } from 'react'
import { JSONEditor, JSONEditorPropsOptional } from 'vanilla-jsoneditor'
const JSONEditorReact = (props) => {
const refContainer = useRef(null)
const refEditor = useRef(null)
useEffect(() => {
// create editor
refEditor.current = createJSONEditor({
target: refContainer.current,
props: {}
})
return () => {
// destroy editor
if (refEditor.current) {
If you are using NextJS, you will need to use a dynamic import to only render the component in the browser (disabling server-side rendering of the wrapper), as shown below in a NextJS TypeScript example.
If you are using React in an conventional non-NextJS browser app, you can import the component using a standard import statement like import JSONEditorReact from '../JSONEditorReact'
//
// demo.tsx for use with NextJS
//
import dynamic from 'next/dynamic'
import { useCallback, useState } from 'react'
//
// In NextJS, when using TypeScript, type definitions
// can be imported from 'vanilla-jsoneditor' using a
// conventional import statement (prefixed with 'type',
// as shown below), but only types can be imported this
// way. When using NextJS, React components and helper
// functions must be imported dynamically using { ssr: false }
// as shown elsewhere in this example.
//
import type { Content, OnChangeStatus } from 'vanilla-jsoneditor'
//
// In NextJS, the JSONEditor component must be wrapped in
// a component that is dynamically in order to turn off
// server-side rendering of the component. This is neccessary
// because the vanilla-jsoneditor code attempts to use
// browser-only JavaScript capabilities not available
// during server-side rendering. Any helper functions
//
// TextContent.tsx
//
// (wrapper around toTextContent for use with NextJS)
//
import { Content, toTextContent } from 'vanilla-jsoneditor'
interface IOwnProps {
content: Content
}
const TextContent = (props: IOwnProps) => {
const { content } = props
return (
<p>
The contents of the editor, converted to a text string, are: {toTextContent(content).text}
</p>
)
}
export default TextContentEstimated unpacked size across 61 packages.
28.0 MB
Includes dependencies.
26 direct · 1 outdated
^8.17.1
8.20.0
^5.0.0
5.57.3
^0.16.0
0.16.0
^4.17.23
4.18.1
^3.0.0
3.15.0
^2.12.3
2.12.3
^0.6.1
0.6.1
^6.8.2
6.9.8
^6.34.1
6.43.15
^1.2.1
1.2.5
^6.4.1
6.7.6
^6.5.6
6.7.2
^6.7.1
6.11.1
^6.10.3
6.13.1
^6.0.1
6.0.3
^1.4.0
1.4.1
^6.0.1
6.0.2
^6.18.1
6.20.4
^3.1.1 || ^4.0.0 || ^5.0.0
5.1.1
1.0.9
^6.6.0 || ^7.0.1
7.3.1
^6.6.0 || ^7.0.1
7.3.1
6.5.3