Semver Comparator
Compare two Semantic Versioning (semver.org) version strings to see which is greater and exactly what changed: major, minor, patch or pre-release.
This guide is not yet available in your language and is shown in English.
Tool guide
What this tool does
Semver Comparator parses two version strings following the Semantic Versioning 2.0.0 specification and determines which is greater, following the spec’s exact precedence rules: numeric major.minor.patch comparison first, then pre-release identifiers (where any pre-release version is lower precedence than the same version without one), with build metadata ignored entirely for comparison purposes.
Semantic Versioning gives version numbers like 1.4.2 or 2.0.0-beta.1 precise, specification-defined meaning, but comparing two of them correctly by eye gets genuinely tricky once pre-release identifiers are involved, since 1.0.0-alpha is specifically defined as lower precedence than the plain 1.0.0 release, which isn’t obvious from the numbers alone.
This comparator parses both version strings according to the Semantic Versioning 2.0.0 specification and applies its exact precedence rules: compare major, then minor, then patch numerically; if those are all equal, compare pre-release identifiers dot-segment by dot-segment (numeric segments compared numerically, alphanumeric segments compared as strings, and a version with no pre-release always outranks one that has one); and ignore build metadata (anything after a +) entirely, since the spec explicitly excludes it from precedence.
How to use Semver Comparator
- Enter Version A.
- Enter Version B.
- Read the Result: which version is greater, or whether they are equal.
- Check Difference type to see exactly which part (major, minor, patch or pre-release) caused the difference.
- Check the Build metadata fields shown for context, since they never affect the comparison itself.
Tips for better results
- A pre-release version is always lower precedence than the same major.minor.patch without one: 1.0.0-rc.1 is considered less than 1.0.0, exactly matching how package managers like npm order pre-release versions before their final release.
- Build metadata (text after a +, like +build.5 or +exp.sha.5114f85) is purely informational under the spec and never affects which version is considered greater, even if the two versions otherwise look identical.
- Numeric pre-release identifiers are compared as numbers, not as strings, so alpha.2 is correctly considered less than alpha.10, unlike a naive string comparison which would get that backwards.
- This comparator is strict about the MAJOR.MINOR.PATCH format; version strings missing the patch number, like just "1.4", are not valid semver and will show an error rather than being guessed at.
Common use cases
- Checking whether a new package version is a major, minor or patch update before upgrading a dependency.
- Verifying that a release pipeline correctly orders pre-release versions below their final release.
- Debugging a dependency resolution or version-range issue by confirming the exact precedence between two specific versions.
- Teaching or reviewing how Semantic Versioning’s precedence rules handle pre-release identifiers and build metadata.
Common mistakes to avoid
- Assuming build metadata affects version ordering; the spec explicitly excludes it from any precedence comparison, so two versions differing only in build metadata are considered equal.
- Comparing pre-release identifiers as plain strings by eye, which gets numeric segments like 2 vs 10 backwards compared to the spec’s numeric-aware comparison rule.
- Forgetting that a version with a pre-release tag is always lower precedence than the same version without one, which can be surprising if read purely as "the numbers are the same".
Frequently asked questions
Why is 1.0.0-alpha considered less than 1.0.0?
The Semantic Versioning spec explicitly defines any version with a pre-release identifier as lower precedence than the same major.minor.patch without one, since a pre-release is, by definition, an earlier, less complete version than the final release.
Does build metadata affect the comparison result?
No, the spec explicitly excludes build metadata (anything after a +) from precedence comparison; two versions differing only in build metadata are treated as equal for comparison purposes.
How are pre-release identifiers like alpha.2 and alpha.10 compared?
Dot-separated segment by segment: purely numeric segments are compared as numbers (so 2 is less than 10), while any alphanumeric segment is compared as a string, matching the spec’s exact precedence rule.
What format does a version string need to be in?
The standard MAJOR.MINOR.PATCH format, optionally followed by a pre-release (-alpha.1) and/or build metadata (+build.5), such as 2.1.0, 1.0.0-rc.1 or 3.2.1+20231115; an optional leading "v" is also accepted.
Feedback & suggestions
Help us improve Semver Comparator. We read every message.