🔍 Power of Browser DevTools inspectors right inside your React app
Installations
npm install react-inspector
Developer Guide
Typescript
Yes
Module System
CommonJS, ESM
Node Version
16.17.1
NPM Version
8.15.0
Releases
Contributors
Unable to fetch Contributors
Languages
TypeScript (64.25%)
JavaScript (35.75%)
Love this project? Help keep it running — sponsor us today! 🚀
Developer
Download Statistics
Total Downloads
821,995,252
Last Day
403,901
Last Week
2,135,548
Last Month
8,891,409
Last Year
129,120,219
GitHub Statistics
MIT License
790 Stars
373 Commits
95 Forks
61 Watchers
12 Branches
143 Contributors
Updated on Feb 13, 2025
Bundle Size
21.42 kB
Minified
6.52 kB
Minified + Gzipped
Package Meta Information
Latest Version
6.0.2
Package Id
react-inspector@6.0.2
Unpacked Size
245.26 kB
Size
58.36 kB
File Count
9
NPM Version
8.15.0
Node Version
16.17.1
Published on
Jun 06, 2023
Total Downloads
Cumulative downloads
Total Downloads
821,995,252
Last Day
-3.3%
403,901
Compared to previous day
Last Week
3%
2,135,548
Compared to previous week
Last Month
45.9%
8,891,409
Compared to previous month
Last Year
-44.3%
129,120,219
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Peer Dependencies
1
Dev Dependencies
36
react-inspector
Power of Browser DevTools inspectors right inside your React app. Check out the interactive playground or storybook.
Install
NPM:
1npm install react-inspector
Recommended versions:
- version
3.0.2
: If you are using React 16.8.4 or later. - version
2.3.1
: If you are using an earlier version of React.
Getting started
<Inspector />
A shorthand for the inspectors.
<Inspector/>
is equivalent to<ObjectInspector>
or<DOMInspector>
if inspecting a DOM Node.<Inspector table/>
is equivalent to<TableInspector>
.
<ObjectInspector />
Like console.log
. Consider this as a glorified version of <pre>JSON.stringify(data, null, 2)</pre>
.
How it works
Tree state is saved at root. If you click to expand some elements in the hierarchy, the state will be preserved after the element is unmounted.
API
The component accepts the following props:
data: PropTypes.any
: the Javascript object you would like to inspect
name: PropTypes.string
: specify the optional name of the root node, default to undefined
expandLevel: PropTypes.number
: an integer specifying to which level the tree should be initially expanded
expandPaths: PropTypes.oneOfType([PropTypes.string, PropTypes.array])
: an array containing all the paths that should be expanded when the component is initialized, or a string of just one path
- The path string is similar to JSONPath.
- It is a dot separated string like
$.foo.bar
.$.foo.bar
expands the path$.foo.bar
where$
refers to the root node. Note that it only expands that single node (but not all its parents and the root node). Instead, you should useexpandPaths={['$', '$.foo', '$.foo.bar']}
to expand all the way to the$.foo.bar
node. - You can refer to array index paths using
['$', '$.1']
- You can use wildcard to expand all paths on a specific level
- For example, to expand all first level and second level nodes, use
['$', '$.*']
(equivalent toexpandLevel={2}
)
- For example, to expand all first level and second level nodes, use
- It is a dot separated string like
- the results are merged with expandLevel
showNonenumerable: PropTypes.bool
: show non-enumerable properties
sortObjectKeys: PropTypes.oneOfType([PropTypes.bool, PropTypes.func])
: Sort object keys with optional compare function
When sortObjectKeys={true}
is provided, keys of objects are sorted in alphabetical order except for arrays.
nodeRenderer: PropTypes.func
: Use a custom nodeRenderer
to render the object properties (optional)
-
Instead of using the default
nodeRenderer
, you can provide a custom function for rendering object properties. The default nodeRender looks like this:1import { ObjectRootLabel, ObjectLabel } from 'react-inspector' 2 3const defaultNodeRenderer = ({ depth, name, data, isNonenumerable, expanded }) => 4 depth === 0 5 ? <ObjectRootLabel name={name} data={data} /> 6 : <ObjectLabel name={name} data={data} isNonenumerable={isNonenumerable} />;
<TableInspector />
Like console.table
.
API
The component accepts the following props:
data: PropTypes.oneOfType([PropTypes.array, PropTypes.object])
: the Javascript object you would like to inspect, either an array or an object
columns: PropTypes.array
: An array of the names of the columns you'd like to display in the table
<DOMInspector />
API
The component accepts the following props:
data: PropTypes.object
: the DOM Node you would like to inspect
Usage
1import { ObjectInspector, TableInspector } from 'react-inspector'; 2 3// or use the shorthand 4import { Inspector } from 'react-inspector'; 5 6const MyComponent = ({ data }) => 7 <div> 8 <ObjectInspector data={data} /> 9 <TableInspector data={data} /> 10 11 <Inspector data={data} /> 12 <Inspector table data={data} /> 13 </div> 14 15let data = { /* ... */ }; 16 17ReactDOM.render( 18 <MyComponent data={data} />, 19 document.getElementById('root') 20);
Try embedding the inspectors inside a component's render() method to provide a live view for its props/state (Works even better with hot reloading).
More Examples
Check out the storybook for more examples.
1npm install && npm run storybook
Theme
By specifying the theme
prop you can customize the inspectors. theme
prop can be
- a string referring to a preset theme (
"chromeLight"
or"chromeDark"
, default to"chromeLight"
) - or a custom object that provides the necessary variables. Checkout
src/styles/themes
for possible theme variables.
Example 1: Using a preset theme:
1<Inspector theme="chromeDark" data={{a: 'a', b: 'b'}}/>
Example 2: changing the tree node indentation by inheriting the chrome light theme:
1import { chromeLight } from 'react-inspector' 2 3<Inspector theme={{...chromeLight, ...({ TREENODE_PADDING_LEFT: 20 })}} data={{a: 'a', b: 'b'}}/>
Roadmap
Type of inspectors:
- Tree style
- common objects
- DOM nodes
- Table style
- Column resizer
- Group style
Contribution
Contribution is welcome. Past contributors
Additional
- If you intend to capture
console.log
s, you may want to look atconsole-feed
. react-object-inspector
package will be deprecated.<ObjectInspector/>
is now part of the new packagereact-inspector
.- Why inline style? This document summarizes it well.

No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
Found 1/9 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/tests-unit.yml:11: update your workflow using https://app.stepsecurity.io/secureworkflow/storybookjs/react-inspector/tests-unit.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/tests-unit.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/storybookjs/react-inspector/tests-unit.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/tests-unit.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/storybookjs/react-inspector/tests-unit.yml/master?enable=pin
- Info: 0 out of 3 GitHub-owned GitHubAction dependencies pinned
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/tests-unit.yml:1
- Info: no jobLevel write permissions found
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 23 are checked with a SAST tool
Reason
39 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-qwcr-r2fm-qrc7
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-x9w5-v3q2-3rhw
- Warn: Project is vulnerable to: GHSA-pxg6-pf52-xh8x
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-434g-2637-qmqr
- Warn: Project is vulnerable to: GHSA-49q7-c7j4-3p7m
- Warn: Project is vulnerable to: GHSA-977x-g7h5-7qgw
- Warn: Project is vulnerable to: GHSA-f7q4-pwc6-w24p
- Warn: Project is vulnerable to: GHSA-fc9h-whq2-v747
- Warn: Project is vulnerable to: GHSA-rv95-896h-c2vc
- Warn: Project is vulnerable to: GHSA-qw6h-vgh9-j6wx
- Warn: Project is vulnerable to: GHSA-78xj-cgh5-2h22
- Warn: Project is vulnerable to: GHSA-2p57-rm9w-gvfp
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-76p3-8jx3-jpfq
- Warn: Project is vulnerable to: GHSA-3rfm-jhwj-7488
- Warn: Project is vulnerable to: GHSA-hhq3-ff78-jv3g
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55
- Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j
- Warn: Project is vulnerable to: GHSA-rhx6-c78j-4q9w
- Warn: Project is vulnerable to: GHSA-7fh5-64p2-3v2j
- Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-m6fv-jmcg-4jfg
- Warn: Project is vulnerable to: GHSA-cm22-4g7w-348p
- Warn: Project is vulnerable to: GHSA-w5hq-hm5m-4548
- Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36
- Warn: Project is vulnerable to: GHSA-4wf5-vphf-c2xc
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
- Warn: Project is vulnerable to: GHSA-w5p7-h5w8-2hfq
- Warn: Project is vulnerable to: GHSA-7p7h-4mm5-852v
- Warn: Project is vulnerable to: GHSA-hc6q-2mpp-qw7j
- Warn: Project is vulnerable to: GHSA-4vvj-4cpr-p986
- Warn: Project is vulnerable to: GHSA-wr3j-pwj9-hqq6
- Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
Score
2.9
/10
Last Scanned on 2025-02-03
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to react-inspector
react-dev-inspector
dev-tool for inspect react components and jump to local IDE for component code.
metro-inspector-proxy
🚇 Inspector proxy for React Native and dev tools integration.
@react-dev-inspector/middleware
express middleware for react-dev-inspector to launch local IDE
@react-dev-inspector/babel-plugin
babel plugin for react-dev-inspector to generate source code position info into jsx properties