Semantic Version Comparator

Compare, sort, increment, and range-test SemVer version numbers with visual diff highlighting.

Last reviewed: June 2026

New to this tool? Click here for instructions

Enter version numbers above.

How to Use the SemVer Comparator

To use the Semantic Version Comparator, follow these steps:

1. Enter two version strings in the 'Version A' and 'Version B' fields.

2. Click the 'Compare' button to see the differences between the two versions.

3. To sort a list of versions, paste them into the 'Try Example' field and click 'Sort'.

4. To increment a version, enter the current version and optionally a pre-release tag in the 'Increment' section.

5. To test a version against a range expression, enter the version and range expression in the 'Range' section.

When to Use the Tool in Real Workflows

The Semantic Version Comparator is ideal for developers who need to manage and compare version numbers in their projects. It is particularly useful when working with npm packages, where understanding version compatibility is crucial. The tool helps ensure that updates to dependencies are made safely and predictably.

How It Works

The tool runs entirely in your browser. JavaScript parses each version into major, minor, patch, and pre-release identifiers; compares each field in SemVer precedence order; sorts valid versions locally; generates common increment targets; and evaluates the range forms implemented by the page, including exact versions, comparators, caret ranges, tilde ranges, wildcards, and OR ranges with ||. No version strings are sent to a backend service.

Tips, Edge Cases, or Limitations

1. SemVer precedence compares major, minor, and patch numerically before considering any pre-release identifiers.

2. Pre-release versions such as 1.0.0-alpha sort before the associated normal release 1.0.0. Numeric pre-release identifiers compare numerically; text identifiers compare lexically.

3. Build metadata after + is parsed for display, but SemVer precedence ignores it when deciding whether one version is greater than another.

4. Range support covers common npm-style forms in the UI: exact versions, >, >=, <, <=, caret, tilde, wildcard, space-separated AND, and || OR expressions.

5. Treat range checks as a planning aid. Package managers may add ecosystem-specific behavior around tags, lockfiles, peer dependencies, and registry metadata that this browser-only comparator does not model.

Sources and further reading

For the underlying versioning rules, see the official Semantic Versioning specification. For npm range syntax, see the npm CLI documentation for semver ranges.

Frequently Asked Questions

Semantic Versioning (SemVer) is a versioning scheme using three numbers: MAJOR.MINOR.PATCH. It provides a way to communicate changes to a software project and ensure that updates to dependencies are made safely and predictably.
The caret (^) range in npm specifies a version range that is compatible with the specified version. For example, ^1.2.3 means that any version greater than or equal to 1.2.3 but less than 2.0.0 is acceptable.
The caret (^) range allows for any minor or patch updates, while the tilde (~) range allows only for patch updates. For example, ^1.2.3 allows for updates to 1.2.x, while ~1.2.3 allows only for updates to 1.2.3.
Pre-release versions have lower precedence than the associated normal version. When comparing pre-release identifiers, numeric identifiers are compared numerically, while alphanumeric identifiers are compared as ASCII strings. A longer set of pre-release identifiers has higher precedence than a shorter set when all preceding identifiers are equal.
You should bump the major version when you make breaking changes to the public API, change a function's behaviour incompatibly, or drop support for a platform/runtime that users depend on. It is generally safe to over-increment, but never safe to under-increment.

Quick reference

Semantic Version Comparator Quick Reference
Version A Version B Comparison Result Notes
1.0.0 1.0.1 A < B Patch update
1.1.0 1.0.0 A > B Minor update
2.0.0 1.9.9 A > B Major version change
1.0.0-alpha 1.0.0 A < B Pre-release vs stable
1.2.3 1.2.3 A = B Exact match
3.4.5 3.4.5-rc1 A > B Stable vs pre-release

Example walk-through

Worked example: step-by-step

Step 1. Input two semantic versions (e.g., "1.2.3" and "1.1.5") into the comparator tool.

Step 2. Split each version into major, minor, and patch components using dot notation.

Step 3. Convert each component to integers and compare them sequentially (major โ†’ minor โ†’ patch).

Step 4. Determine the result: "greater than", "less than", or "equal" based on the first differing component.

Sample input:
version1 = "1.2.3"
version2 = "1.1.5"

Step 5. Output the comparison result using a human-readable message.

Expected output:
"1.2.3 is greater than 1.1.5"

Step 6. Display the result on the webpage with proper formatting and error handling for invalid inputs.