You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
👉 [Try it now](https://virtual-react-json-diff.netlify.app) (See the New Demo Page Including AceEditor)
8
+
👉 [Try it now](https://virtual-react-json-diff.netlify.app)
9
9
10
-
A high-performance React component for visually comparing large JSON objects. Built on top of [json-diff-kit](https://www.npmjs.com/package/json-diff-kit), this viewer supports:
11
-
12
-
- Virtual scrolling for better performance (especially for large diffs)
13
-
- Custom theming (Soon new themes will be available)
14
-
- Dual Mini Map
15
-
- 🔍 Search functionality
16
-
- ⚛️ Optimized for React (uses `react-window`)
17
-
18
-
This component is developed for dealing with thousands of lines of Json Files, and seamlessly compare then render them on UI. Json Compare is a concept that has insufficient FE components available. This component brings solution to the issues of current diff viewers. Virtualized scroll gives a smooth experience while dual minimap and search ability simplifies the process of comparing JSON objects.
10
+
A high-performance React component for visually comparing large JSON objects. Built on top of [json-diff-kit](https://www.npmjs.com/package/json-diff-kit), this viewer supports virtual scrolling, search functionality, dual minimap, and customizable theming.
19
11
20
12
## Features
21
13
22
-
-**Compare Large JSON Objects** – Handles big files without freezing the UI
23
14
-**Virtualized Rendering** – Efficient DOM updates using `react-window`
24
15
-**Search Highlighting** – Find matches and scroll directly to them
25
-
-**Mini Map** – Dual scrollable minimap of Json Diff, scaled to better see comparison result
26
-
-**Customizable Styles** – Add your own class names and styles easily (checkout JsonDiffCustomTheme.css)
16
+
-**Dual Mini Map** – Scrollable minimap for better navigation
17
+
-**Line Count Statistics** – Display added, removed, and modified line counts
18
+
-**Object Count Statistics** – Count objects when using compare-key method
19
+
-**Customizable Styles** – Add your own class names and themes
27
20
28
21
## Demo
29
22
30
-
To see how it works, demo available here: https://virtual-react-json-diff.netlify.app
23
+
👉 [Try it now](https://virtual-react-json-diff.netlify.app) - Interactive demo with live examples
Enable object-level counting when using compare-key method:
75
+
76
+
```jsx
77
+
<VirtualDiffViewer
78
+
oldValue={oldData}
79
+
newValue={newData}
80
+
showObjectCountStats={true}
81
+
differOptions={{
82
+
arrayDiffMethod:"compare-key",
83
+
compareKey:"id"
84
+
}}
85
+
/>;
97
86
```
98
87
99
-
Or if you have a custom Differ or a custom viewer, you can import `Differ` class to create diff objects using your own differ. Moreover you can pass that differ to `VirtualizedDiffViewer`.
|`oldValue`|`object`| — | The original JSON object to compare (left side). |
133
-
|`newValue`|`object`| — | The updated JSON object to compare (right side). |
134
-
|`height`|`number`| — | Height of the diff viewer in pixels. |
135
-
|`hideSearch`|`boolean`|`false`| Hides the search bar if set to `true`. |
136
-
|`searchTerm`|`string`|`""`| Initial search keyword to highlight within the diff. |
137
-
|`leftTitle`|`string`| — | Optional title to display above the left diff panel. |
138
-
|`rightTitle`|`string`| — | Optional title to display above the right diff panel. |
139
-
|`onSearchMatch`|`(index: number) => void`| — | Callback fired when a search match is found. Receives the match index. |
140
-
|`differOptions`|`DifferOptions`|`Given Above`| Advanced options passed to the diffing engine. |
141
-
|`showSingleMinimap`|`boolean`|`false`| If `true`, shows only one minimap instead of two. |
142
-
|`className`|`string`| — | Custom CSS class for styling the viewer container. |
143
-
|`overScanCount`|`number`|`28`| Number of rendered rows outside of the viewport for virtualization |
144
-
|`miniMapWidth`|`number`|`40`| Width of each minimap in pixels. |
145
-
|`inlineDiffOptions`|`InlineDiffOptions`|`{'mode': 'char'}`| Options for fine-tuning inline diff rendering. |
146
-
|`getDiffData`|`(diffData: [DiffResult[], DiffResult[]]) => void`| - | Get difference data and make operations |
147
-
|`customDiffer`|`Differ`| - | Pass custom differ - not recommended |
146
+
The component exposes a root container with class `diff-viewer-container`. You can pass your own class name via the `className` prop to apply custom themes.
148
147
149
148
## 🙌 Acknowledgements
150
149
151
-
Built on top of the awesome json-diff-kit.
150
+
Built on top of the awesome [json-diff-kit](https://www.npmjs.com/package/json-diff-kit).
0 commit comments