The reference implementation: plain ES2020 with zero dependencies, so it runs unchanged in Node, Deno, Bun, browsers and edge workers. It powers the range selector.
vlt install semantic-versions
- Conformance
- 476/476
- vs
semver - 2.4–11×
Libraries
The JavaScript reference implementation and its ports to Rust, Python, Go, Ruby, Java, .NET and PHP. All 8 pass the same 476-case conformance suite, give identical answers on every version and range in the benchmark corpus, and are timed against the libraries they replace on real versions and ranges from the npm registry.
At a glance
| Language | Package | Conformance | Compared with | Speed vs. it |
|---|---|---|---|---|
| JavaScript | semantic-versions | 476/476 | semver 396/476 | 2.4–11× |
| Rust | semantic-versions | 476/476 | nodejs-semver 366/476 | 0.9–1.3× |
| Python | semantic-versions | 476/476 | node-semver 366/476 | 1.5–17× |
| Go | semver.xyz/go | 476/476 | Masterminds/semver 348/436 | 2.8–23× |
| Ruby | semantic-versions | 476/476 | semantic_range 366/476 | 1.7–20× |
| Java | xyz.semver:semantic-versions | 476/476 | semver4j 356/436 | 9.2–26× |
| .NET | SemanticVersions | 476/476 | Semver 365/436 | 1.3–10× |
| PHP | vltpkg/semantic-versions | 476/476 | composer/semver 282/436 | 1.0–3.7× |
Install
The reference implementation: plain ES2020 with zero dependencies, so it runs unchanged in Node, Deno, Bun, browsers and edge workers. It powers the range selector.
vlt install semantic-versions
semverNo dependencies and no unsafe. A Version is 32 bytes, and plain releases parse without allocating.
cargo add semantic-versions
nodejs-semverPure Python 3.10+, typed, no dependencies. Versions order by a precomputed tuple, so sorting runs at C speed.
pip install semantic-versions
node-semverStandard library only. Versions are plain values whose identifiers are slices of the input, so parsing does not allocate.
go get semver.xyz/go
Masterminds/semverPlain Ruby 3.1+, no dependencies. Version is Comparable and Range works with case/when.
gem install semantic-versions
semantic_rangeJava 17+, no dependencies. Immutable, Comparable versions; works from Kotlin, Scala and every other JVM language.
<dependency>
<groupId>xyz.semver</groupId>
<artifactId>semantic-versions</artifactId>
<version>1.0.0</version>
</dependency>
semver4jC# for .NET 8+, no dependencies, AOT-compatible. Scans spans, so parsing allocates only the version itself.
dotnet add package SemanticVersions
SemverPHP 8.1+, no dependencies. Immutable value objects with readonly properties.
composer require vltpkg/semantic-versions
composer/semverJavaScript
semver.Timed against node-semver and @vltpkg/semver, the parser inside vlt, through each library's string API: the way satisfies, maxSatisfying and sort are called in practice. All three cache parsed ranges (this library and vlt's hold 4,096, node-semver an LRU of 1,000), so Parse a range is timed on the constructors, which bypass the caches, while satisfies and maxSatisfying run with them, as in practice.
| Operation | semantic-versions1.0.1 | semver7.8.5 | @vltpkg/semver1.8.1 | vs semver |
|---|---|---|---|---|
| Parse a version5,398 published versions | 100 ns | 284 ns | 267 ns | 2.8× faster |
| Sort versions5,398 versions by precedence (per version) | 428 ns | 4.55 µs | 3.36 µs | 11× faster |
| Parse a range1,996 real dependency ranges (uncached) | 3.04 µs | 7.43 µs | 793 ns | 2.4× faster |
| satisfies(version, range)15,604 version × range checks | 184 ns | 1.06 µs | 313 ns | 5.8× faster |
| Resolve a range116 maxSatisfying lookups against a package's versions | 18.1 µs | 56.2 µs | 33.2 µs | 3.1× faster |
The other libraries implement Semantic Versioning 2.0.0 or their ecosystem's own rules, so they fail where this spec deliberately differs (build precedence, channels and contexts) and wherever they coerce input. That is the gap the spec closes, not a defect in them.
| Feature | semantic-versions | semver | @vltpkg/semver |
|---|---|---|---|
| Version grammarValid and invalid versions per the BNF | 81/81 | 81/81 | 78/81 |
No coercionRejects v1.2.3, =1.2.3, 1.2.3pre, … | 11/11 | 10/11 | 9/11 |
| PrecedenceMajor, minor, patch and pre-release ordering | 32/32 | 32/32 | 32/32 |
Build precedenceA build ranks above its release: 1.0.0 < 1.0.0+b | 16/16 | 1/16 | 1/16 |
RangesComparators, ||, x-ranges, ~, ^, hyphen ranges | 196/196 | 196/196 | 195/196 |
Approximate rangesThe pessimistic operator ~> | 26/26 | 19/26 | 19/26 |
Pre-release channels^1.0.0-rc admits rc.*, never beta | 44/44 | 33/44 | 33/44 |
Pre-release wildcardsX.Y.Z-* and *-* opt in explicitly | 14/14 | 2/14 | 7/14 |
Build channels^1.0.0+win admits +win.* builds only | 41/41 | 19/41 | 23/41 |
Contextsnpm:react@18.2.0, npm:react@^18 | 15/15 | 3/15 | 3/15 |
| All cases | 476/476 | 396/476 | 400/476 |
Rust
nodejs-semver, at most 1.12× slower.Timed against Cargo's semver and npm-compatible nodejs-semver, parsing once and comparing parsed values.
| Operation | semantic-versions1.0.0 | nodejs-semver7.0.0 | semver1.0.28 | vs nodejs-semver |
|---|---|---|---|---|
| Parse a version5398 published versions | 24.8 ns | 27.6 ns | 26.0 ns | 1.1× faster |
| Sort versions5398 parsed versions by precedence (per version) | 132 ns | 118 ns | 142 ns | 1.12× slower |
| Parse a range1996 real dependency ranges | 231 ns | 308 ns | — | 1.3× faster |
| Range::test(version)15604 version × range checks | 7.4 ns | 9.4 ns | — | 1.3× faster |
| Resolve a range116 max-satisfying lookups against a package's versions | 1.24 µs | 1.54 µs | — | 1.2× faster |
The other libraries implement Semantic Versioning 2.0.0 or their ecosystem's own rules, so they fail where this spec deliberately differs (build precedence, channels and contexts) and wherever they coerce input. That is the gap the spec closes, not a defect in them.
| Feature | semantic-versions | nodejs-semver | semver |
|---|---|---|---|
| Version grammarValid and invalid versions per the BNF | 81/81 | 59/81 | 81/81 |
No coercionRejects v1.2.3, =1.2.3, 1.2.3pre, … | 11/11 | 3/11 | 11/11 |
| PrecedenceMajor, minor, patch and pre-release ordering | 32/32 | 32/32 | 32/32 |
Build precedenceA build ranks above its release: 1.0.0 < 1.0.0+b | 16/16 | 1/16 | 15/16 |
RangesComparators, ||, x-ranges, ~, ^, hyphen ranges | 196/196 | 192/196 | 134/169 |
Approximate rangesThe pessimistic operator ~> | 26/26 | 19/26 | 9/19 |
Pre-release channels^1.0.0-rc admits rc.*, never beta | 44/44 | 33/44 | 34/44 |
Pre-release wildcardsX.Y.Z-* and *-* opt in explicitly | 14/14 | 2/14 | 2/13 |
Build channels^1.0.0+win admits +win.* builds only | 41/41 | 22/41 | 19/36 |
Contextsnpm:react@18.2.0, npm:react@^18 | 15/15 | 3/15 | 3/15 |
| All cases | 476/476 | 366/476 | 340/436 |
Python
node-semver.Timed against node-semver (npm's rules, ported to Python) and python-semver, parsing once and comparing parsed values.
| Operation | semantic-versions1.0.0 | node-semver0.9.1 | semver3.1.2 | vs node-semver |
|---|---|---|---|---|
| Parse a version5398 published versions | 1.05 µs | 1.60 µs | 1.64 µs | 1.5× faster |
| Sort versions5398 parsed versions by precedence (per version) | 645 ns | 11.1 µs | 7.04 µs | 17× faster |
| Parse a range1996 real dependency ranges | 4.15 µs | 15.5 µs | — | 3.7× faster |
| range.test(version)15604 version × range checks | 229 ns | 2.01 µs | — | 8.8× faster |
| Resolve a range116 max-satisfying lookups against a package's versions | 47.5 µs | 319.8 µs | — | 6.7× faster |
The other libraries implement Semantic Versioning 2.0.0 or their ecosystem's own rules, so they fail where this spec deliberately differs (build precedence, channels and contexts) and wherever they coerce input. That is the gap the spec closes, not a defect in them.
| Feature | semantic-versions | node-semver | semver |
|---|---|---|---|
| Version grammarValid and invalid versions per the BNF | 81/81 | 80/81 | 80/81 |
No coercionRejects v1.2.3, =1.2.3, 1.2.3pre, … | 11/11 | 10/11 | 7/7 |
| PrecedenceMajor, minor, patch and pre-release ordering | 32/32 | 32/32 | 32/32 |
Build precedenceA build ranks above its release: 1.0.0 < 1.0.0+b | 16/16 | 1/16 | 1/16 |
RangesComparators, ||, x-ranges, ~, ^, hyphen ranges | 196/196 | 171/196 | n/a |
Approximate rangesThe pessimistic operator ~> | 26/26 | 15/26 | n/a |
Pre-release channels^1.0.0-rc admits rc.*, never beta | 44/44 | 33/44 | n/a |
Pre-release wildcardsX.Y.Z-* and *-* opt in explicitly | 14/14 | 2/14 | n/a |
Build channels^1.0.0+win admits +win.* builds only | 41/41 | 19/41 | n/a |
Contextsnpm:react@18.2.0, npm:react@^18 | 15/15 | 3/15 | 0/8 |
| All cases | 476/476 | 366/476 | 120/144 |
Go
Masterminds/semver.Timed against Masterminds/semver, the most widely used Go library with npm-style constraints, and blang/semver, parsing once and comparing parsed values.
| Operation | semantic-versions1.0.0 | Masterminds/semver3.5.0 | blang/semver4.0.0 | vs Masterminds/semver |
|---|---|---|---|---|
| Parse a version5398 published versions | 31.1 ns | 602 ns | 173 ns | 19× faster |
| Sort versions5398 parsed versions by precedence (per version) | 203 ns | 558 ns | 262 ns | 2.8× faster |
| Parse a range1996 real dependency ranges | 388 ns | 6.91 µs | — | 18× faster |
| Range.Test(version)15604 version × range checks | 28.4 ns | 647 ns | — | 23× faster |
| Resolve a range116 max-satisfying lookups against a package's versions | 4.26 µs | 95.5 µs | — | 22× faster |
The other libraries implement Semantic Versioning 2.0.0 or their ecosystem's own rules, so they fail where this spec deliberately differs (build precedence, channels and contexts) and wherever they coerce input. That is the gap the spec closes, not a defect in them.
| Feature | semantic-versions | Masterminds/semver | blang/semver |
|---|---|---|---|
| Version grammarValid and invalid versions per the BNF | 81/81 | 74/81 | 81/81 |
No coercionRejects v1.2.3, =1.2.3, 1.2.3pre, … | 11/11 | 10/11 | 11/11 |
| PrecedenceMajor, minor, patch and pre-release ordering | 32/32 | 32/32 | 32/32 |
Build precedenceA build ranks above its release: 1.0.0 < 1.0.0+b | 16/16 | 1/16 | 1/16 |
RangesComparators, ||, x-ranges, ~, ^, hyphen ranges | 196/196 | 164/169 | 114/169 |
Approximate rangesThe pessimistic operator ~> | 26/26 | 15/19 | 9/19 |
Pre-release channels^1.0.0-rc admits rc.*, never beta | 44/44 | 28/44 | 29/44 |
Pre-release wildcardsX.Y.Z-* and *-* opt in explicitly | 14/14 | 2/13 | 2/13 |
Build channels^1.0.0+win admits +win.* builds only | 41/41 | 19/36 | 21/36 |
Contextsnpm:react@18.2.0, npm:react@^18 | 15/15 | 3/15 | 3/15 |
| All cases | 476/476 | 348/436 | 303/436 |
Ruby
semantic_range.Timed against semantic_range (node-semver ported to Ruby, used by Libraries.io) and RubyGems' own Gem::Version, parsing once and comparing parsed values.
| Operation | semantic-versions1.0.0 | semantic_range3.1.1 | Gem::Version3.5.22 | vs semantic_range |
|---|---|---|---|---|
| Parse a version5398 published versions | 1.36 µs | 2.25 µs | 1.23 µs | 1.7× faster |
| Sort versions5398 parsed versions by precedence (per version) | 2.56 µs | 23.6 µs | 4.40 µs | 9.2× faster |
| Parse a range1996 real dependency ranges | 8.48 µs | 31.2 µs | — | 3.7× faster |
| range.test(version)15604 version × range checks | 376 ns | 7.38 µs | — | 20× faster |
| Resolve a range116 max-satisfying lookups against a package's versions | 60.4 µs | 1.04 ms | — | 17× faster |
The other libraries implement Semantic Versioning 2.0.0 or their ecosystem's own rules, so they fail where this spec deliberately differs (build precedence, channels and contexts) and wherever they coerce input. That is the gap the spec closes, not a defect in them.
| Feature | semantic-versions | semantic_range | Gem::Version |
|---|---|---|---|
| Version grammarValid and invalid versions per the BNF | 81/81 | 80/81 | 37/81 |
No coercionRejects v1.2.3, =1.2.3, 1.2.3pre, … | 11/11 | 10/11 | 9/11 |
| PrecedenceMajor, minor, patch and pre-release ordering | 32/32 | 32/32 | 24/32 |
Build precedenceA build ranks above its release: 1.0.0 < 1.0.0+b | 16/16 | 1/16 | 1/16 |
RangesComparators, ||, x-ranges, ~, ^, hyphen ranges | 196/196 | 171/196 | 104/169 |
Approximate rangesThe pessimistic operator ~> | 26/26 | 15/26 | 19/19 |
Pre-release channels^1.0.0-rc admits rc.*, never beta | 44/44 | 33/44 | 32/44 |
Pre-release wildcardsX.Y.Z-* and *-* opt in explicitly | 14/14 | 2/14 | 2/13 |
Build channels^1.0.0+win admits +win.* builds only | 41/41 | 19/41 | 19/36 |
Contextsnpm:react@18.2.0, npm:react@^18 | 15/15 | 3/15 | 3/15 |
| All cases | 476/476 | 366/476 | 250/436 |
Java
semver4j.Timed against semver4j (npm-compatible ranges) and java-semver, parsing once and comparing parsed values, after a one-second JIT warm-up.
| Operation | semantic-versions1.0.0 | semver4j6.0.0 | java-semver0.10.2 | vs semver4j |
|---|---|---|---|---|
| Parse a version5398 published versions | 42.5 ns | 611 ns | 319 ns | 14× faster |
| Sort versions5398 parsed versions by precedence (per version) | 134 ns | 1.24 µs | 157 ns | 9.3× faster |
| Parse a range1996 real dependency ranges | 248 ns | 6.47 µs | — | 26× faster |
| range.test(version)15604 version × range checks | 7.7 ns | 70.7 ns | — | 9.2× faster |
| Resolve a range116 max-satisfying lookups against a package's versions | 1.18 µs | 15.5 µs | — | 13× faster |
The other libraries implement Semantic Versioning 2.0.0 or their ecosystem's own rules, so they fail where this spec deliberately differs (build precedence, channels and contexts) and wherever they coerce input. That is the gap the spec closes, not a defect in them.
| Feature | semantic-versions | semver4j | java-semver |
|---|---|---|---|
| Version grammarValid and invalid versions per the BNF | 81/81 | 81/81 | 81/81 |
No coercionRejects v1.2.3, =1.2.3, 1.2.3pre, … | 11/11 | 10/11 | 11/11 |
| PrecedenceMajor, minor, patch and pre-release ordering | 32/32 | 31/32 | 32/32 |
Build precedenceA build ranks above its release: 1.0.0 < 1.0.0+b | 16/16 | 1/16 | 13/16 |
RangesComparators, ||, x-ranges, ~, ^, hyphen ranges | 196/196 | 161/169 | 124/169 |
Approximate rangesThe pessimistic operator ~> | 26/26 | 15/19 | 9/19 |
Pre-release channels^1.0.0-rc admits rc.*, never beta | 44/44 | 33/44 | 26/44 |
Pre-release wildcardsX.Y.Z-* and *-* opt in explicitly | 14/14 | 2/13 | 2/13 |
Build channels^1.0.0+win admits +win.* builds only | 41/41 | 19/36 | 21/36 |
Contextsnpm:react@18.2.0, npm:react@^18 | 15/15 | 3/15 | 3/15 |
| All cases | 476/476 | 356/436 | 322/436 |
.NET
Semver.Timed against Semver, the most downloaded .NET version library (npm ranges via SemVersionRange.ParseNpm), and SemanticVersioning, a port of node-semver, after a one-second JIT warm-up.
| Operation | semantic-versions1.0.0 | Semver3.0.0 | SemanticVersioning3.0.0 | vs Semver |
|---|---|---|---|---|
| Parse a version5398 published versions | 36.6 ns | 373 ns | 594 ns | 10× faster |
| Sort versions5398 parsed versions by precedence (per version) | 101 ns | 162 ns | 778 ns | 1.6× faster |
| Parse a range1996 real dependency ranges | 330 ns | 712 ns | 18.2 µs | 2.2× faster |
| range.Test(version)15604 version × range checks | 7.5 ns | 9.6 ns | 74.9 ns | 1.3× faster |
| Resolve a range116 max-satisfying lookups against a package's versions | 1.44 µs | 2.02 µs | 32.3 µs | 1.4× faster |
The other libraries implement Semantic Versioning 2.0.0 or their ecosystem's own rules, so they fail where this spec deliberately differs (build precedence, channels and contexts) and wherever they coerce input. That is the gap the spec closes, not a defect in them.
| Feature | semantic-versions | Semver | SemanticVersioning |
|---|---|---|---|
| Version grammarValid and invalid versions per the BNF | 81/81 | 80/81 | 57/81 |
No coercionRejects v1.2.3, =1.2.3, 1.2.3pre, … | 11/11 | 11/11 | 7/11 |
| PrecedenceMajor, minor, patch and pre-release ordering | 32/32 | 32/32 | 32/32 |
Build precedenceA build ranks above its release: 1.0.0 < 1.0.0+b | 16/16 | 1/16 | 1/16 |
RangesComparators, ||, x-ranges, ~, ^, hyphen ranges | 196/196 | 169/169 | 169/169 |
Approximate rangesThe pessimistic operator ~> | 26/26 | 15/19 | 9/19 |
Pre-release channels^1.0.0-rc admits rc.*, never beta | 44/44 | 33/44 | 33/44 |
Pre-release wildcardsX.Y.Z-* and *-* opt in explicitly | 14/14 | 2/13 | 2/13 |
Build channels^1.0.0+win admits +win.* builds only | 41/41 | 19/36 | 19/36 |
Contextsnpm:react@18.2.0, npm:react@^18 | 15/15 | 3/15 | 3/15 |
| All cases | 476/476 | 365/436 | 332/436 |
PHP
composer/semver.Timed against composer/semver, the constraint engine inside Composer, and z4kn4fein/php-semver, parsing once and comparing parsed values.
| Operation | semantic-versions1.0.0 | composer/semver3.6.0 | z4kn4fein/php-semver3.0.0 | vs composer/semver |
|---|---|---|---|---|
| Parse a version5398 published versions | 440 ns | 1.00 µs | 755 ns | 2.3× faster |
| Sort versions5398 parsed versions by precedence (per version) | 1.99 µs | 1.94 µs | 2.61 µs | about the same |
| Parse a range797 real dependency ranges | 2.77 µs | 2.85 µs | 3.26 µs | about the same |
| range->test(version)13654 version × range checks | 205 ns | 741 ns | 601 ns | 3.6× faster |
| Resolve a range103 max-satisfying lookups against a package's versions | 33.4 µs | 124.1 µs | 86.7 µs | 3.7× faster |
The other libraries implement Semantic Versioning 2.0.0 or their ecosystem's own rules, so they fail where this spec deliberately differs (build precedence, channels and contexts) and wherever they coerce input. That is the gap the spec closes, not a defect in them.
| Feature | semantic-versions | composer/semver | z4kn4fein/php-semver |
|---|---|---|---|
| Version grammarValid and invalid versions per the BNF | 81/81 | 57/81 | 80/81 |
No coercionRejects v1.2.3, =1.2.3, 1.2.3pre, … | 11/11 | 8/11 | 11/11 |
| PrecedenceMajor, minor, patch and pre-release ordering | 32/32 | 18/32 | 32/32 |
Build precedenceA build ranks above its release: 1.0.0 < 1.0.0+b | 16/16 | 1/16 | 1/16 |
RangesComparators, ||, x-ranges, ~, ^, hyphen ranges | 196/196 | 138/169 | 161/169 |
Approximate rangesThe pessimistic operator ~> | 26/26 | 9/19 | 15/19 |
Pre-release channels^1.0.0-rc admits rc.*, never beta | 44/44 | 26/44 | 19/44 |
Pre-release wildcardsX.Y.Z-* and *-* opt in explicitly | 14/14 | 2/13 | 2/13 |
Build channels^1.0.0+win admits +win.* builds only | 41/41 | 20/36 | 19/36 |
Contextsnpm:react@18.2.0, npm:react@^18 | 15/15 | 3/15 | 3/15 |
| All cases | 476/476 | 282/436 | 343/436 |
Other languages
Missing yours? Everything needed to build one is published: the specification, the BNF grammars, and the conformance suite as plain JSON. An implementation that passes every case behaves like the ones above. Open an issue and it can be listed here.