react-json-tree is a React component that provides an interactive JSON viewer, allowing developers to inspect JavaScript objects and arrays in a collapsible tree format. It was originally extracted from the Redux DevTools project and maintains active development within the same monorepo. The current stable version is 0.20.0, indicating a mature library. It differentiates itself by supporting iterable objects, including those from Immutable.js, and offering extensive theming capabilities through the base16 specification or custom styling functions. The component is regularly maintained, though its release cadence for major versions is tied to the broader Redux DevTools ecosystem. It's primarily used in development tools, debugging interfaces, and administrative dashboards where visual inspection of data structures is crucial.
npm install react-json-treeVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to render a complex JavaScript object, including Immutable.js `Map` instances, using the `JSONTree` component with a custom theme and initial expansion logic.
Upgrade `react` and `@types/react` to compatible versions. Check the package's `peerDependencies` in `package.json` for the exact supported ranges.
Refer to the `react-json-tree` README and `createStylingFromTheme.ts` source for detailed documentation on `theme` prop structure and accepted styling keys, including the use of `extend` property for base16 themes.
Monitor release notes for `react-json-tree` and related Redux DevTools packages. For new projects, prefer ESM import syntax (`import`) and ensure your build tooling (e.g., Webpack, Rollup) is configured to handle ESM correctly. For older CJS projects, consider using dynamic `import()` or upgrading to a modern build setup.
Ensure you are using `import { JSONTree } from 'react-json-tree'` for ESM. If in a CJS file, verify `require('react-json-tree').JSONTree` works, or adapt your build configuration to handle ESM imports. If an older CJS context has issues, consider using dynamic `import()` for `react-json-tree`.Ensure the `data` prop passed to `JSONTree` is a valid JavaScript object, array, or an iterable. To display primitive values, wrap them in an object, e.g., `<JSONTree data={{ value: 'hello world' }} />`.Verify that `react` and `react-dom` are installed and configured correctly in your project. Check `react-json-tree`'s `peerDependencies` in `package.json` to ensure your project's React versions are compatible. Reinstall project dependencies via `npm install` or `yarn install` to resolve potential corruption.