Prerelease ordering and isolation: beta.11 beats beta.2
In one line: SemVer 2.0.0 §11 precedence, and how npm and Cargo keep prereleases out of ranges unless you ask for them.
Prereleases exist to order release candidates. Two rules live side by side: the specification defines ordering, and each tool defines whether a range admits prereleases.
§11 precedence, in one line
1.0.0-alpha < 1.0.0-alpha.1 < 1.0.0-alpha.beta < 1.0.0-beta
< 1.0.0-beta.2 < 1.0.0-beta.11 < 1.0.0-rc.1 < 1.0.0
Three rules: numeric identifiers compare as numbers, a numeric identifier is lower than an alphanumeric one, and alphanumeric identifiers compare in ASCII order. With different lengths, compare the common prefix and the longer set is greater. Hence beta.2 < beta.11 and alpha < alpha.1.
Build metadata is not ordered
1.0.0+build.1 and 1.0.0+build.2 have equal precedence. Sorting cannot decide between them, and they count as the same version. That is why the sorter keeps input order for equal-precedence entries.
The specification has no ranges
SemVer defines comparison, not range syntax. Whether >=1.0.0 admits 1.5.0-beta is a tool decision. The SemVer 2.0.0 mode on this site compares prereleases plainly, so you can see pure precedence. npm and Cargo modes apply isolation.
npm and Cargo isolation
A prerelease version passes only when the range contains a comparator that names the same major.minor.patch and carries a prerelease.
| Version | Range | Result | Reason |
|---|---|---|---|
| 1.2.3-beta.2 | >=1.2.3-beta.1 <2.0.0 | pass | a comparator names the prerelease of 1.2.3 |
| 1.5.0-beta.1 | >=1.2.3-beta.1 <2.0.0 | fail | no comparator names a prerelease of 1.5.0 |
| 1.5.0 | >=1.2.3-beta.1 <2.0.0 | pass | stable versions are not isolated |
| 2.0.0-alpha | ^1.2.3 | fail | outside the <2.0.0-0 bound |
The policy is "prereleases only when explicitly requested", which keeps ^1.2.3 from pulling in 1.9.0-rc.1 by accident.
Ordering and ranges together
0.3.0-0 sorts below 0.3.0-alpha because numeric 0 is lower than alphanumeric alpha. That makes <0.3.0-0 an upper bound that excludes every prerelease of 0.3.0 — the exact reason range upper bounds carry -0.
Paste the same constraints and candidate versions into this page to see which versions survive.
Open SemVerLabFrequently asked questions
Which is greater, 1.0.0-alpha.1 or 1.0.0-alpha.beta?
alpha.beta. The second identifier compares numeric 1 with alphanumeric beta, and numeric is lower.
Is beta.11 really greater than beta.2?
Yes, numeric identifiers compare as numbers, so 11 > 2. String sorting would say otherwise.
Does different build metadata mean a different version?
Precedence is equal. The strings differ, so some package managers treat them as separate artifacts.
Sources
Read next
- The npm
^0.xtrap: why 0.3.0 falls outsideWhy^0.2.3ends at<0.3.0-0, how node-semver builds that bound, and which range to use for 0.x dependencies. - Cargo's
0.0.xand0.x: the patch is the boundaryWhy a bare version in Cargo means caret, why^0.0.3accepts only 0.0.3, and how commas and the missing||work. - PEP 440
~=with post and dev: three rules in one operatorHow~=1.4.2computes its upper bound, how dev/pre/post order, and what epochs, local versions and.*do.