
Security News
Happy Birthday, Shai-Hulud
It has been one year since Shai-Hulud made its first appearance on npm.
@crashbytes/react-version-compare
Advanced tools
A React component for comparing strings and arrays with precise word-level and item-level highlighting of differences.
A React component for comparing strings and arrays with precise word-level and item-level highlighting of differences.
You can explore and interact with all features of this component in the live Storybook:
The Storybook provides interactive examples for all comparison scenarios. You can adjust the inputs and props using the controls panel to see how the component behaves with different data. This is the best way to preview, test, and understand the capabilities of react-version-compare without writing any code.
npm install @crashbytes/react-version-compare
yarn add @crashbytes/react-version-compare
import React from 'react';
import Compare from '@crashbytes/react-version-compare';
import '@crashbytes/react-version-compare/dist/styles.css';
const App = () => {
const original = 'I am Captain Kirk, Captain of the USS Enterprise.';
const modified = 'I am Captain Picard, Captain of the USS Enterprise.';
return (
<Compare
original={original}
modified={modified}
/>
);
};
Result: Only "Kirk" (in red) and "Picard" (in green) will be highlighted.
const originalArray = [
'First item',
'Second item',
'Third item'
];
const modifiedArray = [
'First item',
'Modified second item',
'Third item'
];
<Compare
original={originalArray}
modified={modifiedArray}
/>
The component now supports comparing Contentful Rich Text documents with two different modes:
import { Compare } from '@crashbytes/react-version-compare';
import { Document } from '@contentful/rich-text-types';
// Text mode - extracts plain text for comparison
<Compare
original={contentfulDoc1}
modified={contentfulDoc2}
compareMode="text"
viewMode="side-by-side"
/>
// Structure mode - compares document structure
<Compare
original={contentfulDoc1}
modified={contentfulDoc2}
compareMode="structure"
viewMode="side-by-side"
/>
Structure Mode preserves the semantic meaning of the document by comparing:
Text Mode extracts plain text content and performs word-level comparison, similar to string comparison.
| Prop | Type | Default | Description |
|---|---|---|---|
original | string | string[] | Document | required | The original content |
modified | string | string[] | Document | required | The modified content |
viewMode | 'side-by-side' | 'inline' | 'side-by-side' | How to display the comparison |
className | string | '' | Custom CSS class name |
caseSensitive | boolean | true | Whether comparison is case sensitive |
compareMode | 'text' | 'structure' | 'text' | Comparison mode for Contentful documents |
// Example 1: Minimal changes
const original = 'I am Captain Kirk, Captain of the USS Enterprise.';
const modified = 'I am Captain Picard, Captain of the USS Enterprise.';
// Only "Kirk" → "Picard" highlighted
// Example 2: Multiple changes
const original = 'I am Captain Kirk, Captain of the USS Enterprise.';
const modified = 'I am Commander Benjamin Sisko, Commander of Deep Space 9.';
// Highlights: "Captain Kirk, Captain of the USS Enterprise" → "Commander Benjamin Sisko, Commander of Deep Space 9"
const original = ['Item A', 'Item B', 'Item C'];
const modified = ['Item A', 'Modified Item B', 'Item C', 'Item D'];
<Compare original={original} modified={modified} />
<Compare
original="Original text"
modified="Modified text"
viewMode="inline"
/>
The component uses CSS classes that you can customize:
.diff-removed {
/* Styling for removed content (red) */
}
.diff-added {
/* Styling for added content (green) */
}
.diff-unchanged {
/* Styling for unchanged content */
}
Apache License 2.0 - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
If you encounter any issues or have questions, please open an issue on GitHub.
See CHANGELOG.md for release history.
To bump the version, use npm version:
npm version patch # or 'minor' or 'major'
This will update package.json, create a git tag, and (optionally) commit the change.
FAQs
A React component for comparing strings and arrays with precise word-level and item-level highlighting of differences.
The npm package @crashbytes/react-version-compare receives a total of 23 weekly downloads. As such, @crashbytes/react-version-compare popularity was classified as not popular.
We found that @crashbytes/react-version-compare demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.

Security News
It has been one year since Shai-Hulud made its first appearance on npm.

Research
/Security News
Operators behind PolinRider used a compromised GitHub account to plant malware in four development versions of a Packagist package with 700,000+ downloads.

Security News
GitHub Actions now supports cache-mode, a least-privilege control on the Actions cache aimed at the cache poisoning technique behind recent compromises.