Semver Comparator
Compare semver versions, inspect major/minor/patch/prerelease, and test satisfaction against npm-style ranges.
Compare semantic versions and test npm-style ranges
Libraries and services publish Semantic Versioning strings such as
2.4.1 or 1.0.0-beta.3. Package managers use those numbers to decide upgrades and compatibility.
This comparator uses the same rules as the npm semver package: order two versions, break them into
major/minor/patch/prerelease/build parts, and check whether a version satisfies a range expression.
Range syntax
Supports comparators (>=1.2.3), caret (^1.0.0), tilde (~1.2.3),
hyphen ranges, space-separated AND groups, and || OR clauses. Prerelease versions are included when testing ranges unless you pin an exact version.
When packaging APIs, pair this with deployment checklists and changelog discipline so consumers know which range your service guarantees.
Frequently Asked Questions
Why does 1.2.10 sort higher than 1.2.3?
Semver compares numeric identifiers, not strings. Patch 10 is greater than patch 3.
Are build metadata segments compared?
Build metadata after + is shown when parsed but ignored for precedence, per the semver specification.
Does this match npm and Node?
Range satisfaction uses the same semver library bundled with the npm ecosystem, so results align with npm install dependency resolution for equivalent range strings.