npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

react-plain-json-editor

v1.2.0

Published

Provide a simple JSON editor for React

Readme

react-plain-json-editor

It provides simple JSON editor for React.
live demo

you can use this either as a Component(PlainJsonEditor) or as a Hook(useJsonEditor).

Install

npm i react-plain-json-editor
or
yarn add react-plain-json-editor

How to use

PlainJsonEditor

note: all properties are optional.

<PlainJsonEditor
	// initial JSON content of the editor. provide it as an object.
	// default: {}
	value={{initial:"value"}}
	// fires every time it successfully parsed into a JSON value.
	// default: empty function
	onChange={handleChange}
	// fires when submit key pressed and successfully parsed.
	// default: empty function
	onSubmit={handleSubmit}
	// trigger keys to emit 'onSubmit'.
	// you can set any combinations of keys that are provided in [Hotkeys.js](https://wangchujiang.com/hotkeys/).
	// default: ["command+enter", "ctrl+enter"]
	submitKeys={["command+s"]}
	// error string to show if you have any.
	// default: ""
	error=""
	// whether shows inner error(most of the cases it's a parsing error) or not.
	// default: true
	showInnerError={true}
	// custom serialize(string=>JSON) function if you have any.
	// default: JSON.parse
	serializer={JSON.parse}
	// custom deserialise(JSON=>string) function if you have any.
	// default: JSON.stringify(json, null, 2)
	deserializer={json => { return JSON.stringify(json, null, 2) }}
	// format(serialise=>deserialise=>setText) text in the editor after submitting.
	// default: true
	formatAfterSubmit={true}
	// customize styles of each inner element.
	// you can specify "root", "textarea", and "error".
	// if you set the styles, they are merged into default styles(see src/PlainJsonEditor.tsx).
	// default: {}
	styles={{
		textarea: {
			backgroundColor: "rgba(0,0,0,0.8)",
			color: "#CFF",
			padding: 12,
			fontSize: "1.2rem",
			lineHeight: "1.5rem",
			fontFamily: "monospace"
		}
	}}
/>

PlainJsonEditor is enough but if you want to use it more (more!) simple way, there is a hook style useJsonEditor for you.

useJsonEditor

This is useful especially the cases that...

  • you want to have full accessibility of textarea
  • you want to handle inner(parsing) error by yourself

note: all properties are optional.

function YourComponent = () => {
	// useJsonEditor returns a ref so that you can bind it with your `textarea` element.
	const editorRef = useJsonEditor = ({
		onSubmit = {handleSubmit},
		onError = {handleError},
		// submitKeys = ['command+enter', 'ctrl+enter'],
		// serializer = JSON.parse
	})
	return (
		<textarea
			// bind useJsonEditor hook with an element
			ref={editorRef}
			// if you need onChange event, you can pass it as usual
			onChange={handleChange}
			// other properties are of course valid because it is a normal textarea
			// value=""
		/>
	)
}