Semver Comparator & Checker
About
Semantic Versioning (semver.org) gives version numbers a contract: MAJOR for breaking changes, MINOR for backward-compatible features, PATCH for backward-compatible fixes — plus pre-release suffixes (1.0.0-alpha < 1.0.0-alpha.1 < 1.0.0-beta < 1.0.0) and +build metadata that never affects precedence. The comparator implements the spec's precedence algorithm exactly, including the fiddly pre-release rules (numeric identifiers compare numerically and rank below alphanumeric ones; a version with a pre-release is older than the same version without). It is the check CI pipelines and package managers run millions of times a day.
Frequently Asked Questions
Is 1.0.0-alpha newer than 1.0.0?
No — a pre-release is older than its release: 1.0.0-alpha < 1.0.0. That is the rule that lets package managers offer betas safely.
Does +build metadata matter?
Not for precedence: 1.0.0+exp and 1.0.0 are equal in ordering, though the metadata is preserved for information.