What is vanilla-jsoneditor?
The vanilla-jsoneditor is a lightweight and flexible JSON editor that allows users to view, edit, and format JSON data. It provides a user-friendly interface for handling JSON data, making it easier to work with complex JSON structures.
What are vanilla-jsoneditor's main functionalities?
JSON Editing
This feature allows users to create an instance of the JSON editor and set JSON data for editing. The editor provides a user-friendly interface to modify JSON objects.
const editor = new JSONEditor(container, options); editor.set({"name": "John", "age": 30});
JSON Validation
The JSON editor can validate the JSON data to ensure it is correctly formatted. This feature helps in identifying errors in the JSON structure.
editor.validate();
JSON Formatting
This feature allows users to format JSON data for better readability. It automatically indents and organizes the JSON structure.
editor.format();
Other packages similar to vanilla-jsoneditor
jsoneditor
The jsoneditor package is a web-based tool to view, edit, format, and validate JSON data. It offers a rich set of features including a tree view and text view, which makes it more versatile compared to vanilla-jsoneditor.
react-json-view
react-json-view is a React component for displaying and editing JSON data. It provides a more interactive experience with features like inline editing and collapsible nodes, which can be more suitable for React applications compared to vanilla-jsoneditor.
jsoneditor-react
jsoneditor-react is a React wrapper for the jsoneditor library, providing the same functionalities as jsoneditor but specifically designed for React applications. It offers a seamless integration with React projects, unlike vanilla-jsoneditor which is framework agnostic.
vanilla-jsoneditor
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.
Features
- View and edit JSON
- Has a low level text mode and high level tree mode
- Format (beautify) and compact JSON
- Sort, query, filter, and transform JSON
- Repair JSON
- JSON schema validation and pluggable custom validation
- Color highlighting, undo/redo, search and replace
- Utilities like a color picker and timestamp tag
- Handles large JSON documents up to 500 MB
Install
Install using npm:
npm install vanilla-jsoneditor
Remark: for usage in a Svelte project, install svelte-jsoneditor
instead.
Use
Browser example loading the ES module:
<!DOCTYPE html>
<html lang="en">
<head>
<title>JSONEditor</title>
</head>
<body>
<div id="jsoneditor"></div>
<script type="module">
import { JSONEditor } from 'vanilla-jsoneditor'
let content = {
text: undefined,
json: {
greeting: 'Hello World'
}
}
const editor = new JSONEditor({
target: document.getElementById('jsoneditor'),
props: {
content,
onChange: (updatedContent, previousContent, { contentErrors, patchResult }) => {
console.log('onChange', { updatedContent, previousContent, contentErrors, patchResult })
content = updatedContent
}
}
})
</script>
</body>
</html>
Documentation
For documentation, see: https://github.com/josdejong/svelte-jsoneditor