A pure JavaScript library that renders JSON objects as collapsible HTML trees, featuring hover preview, theme support (e.g., dark mode), animation toggles, and property sorting. Current stable version 2.4.9, maintained on GitHub with weekly releases. Unlike other JSON viewers, it provides configurable open depth, hover preview for arrays and objects, and uses the object's toJSON method. Requires peer dependency 'select', ships TypeScript definitions.
npm install json-formatter-js-extendedNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Renders a JSON object as a collapsible HTML tree with initial open depth of 2 and hover preview enabled.
If you have a JSON string, parse it first: JSON.parse(str). The library does not accept raw strings.
Use require('json-formatter-js').default to get the class.No fix needed, but be explicit with depth.
Run npm install select@^1.1.2 alongside json-formatter-js.
Set config: { useToJSON: false } if you want to show the object structure instead of the string output.Use import JSONFormatter from 'json-formatter-js' (no curly braces).
Run npm install select@^1.1.2 to install the peer dependency.
Use document.body.appendChild(formatter.render()); — render() returns an element, not a function.