Developer Tools
Semantic Version Comparator
Compare SemVer versions and inspect prerelease precedence.
SemVer precedence
1.4.0-beta.2 < 1.4.0
The first version has lower precedence.
1.4.0-beta.2
- Core
- 1.4.0
- Prerelease
- beta.2
- Build
- None
1.4.0
- Core
- 1.4.0
- Prerelease
- None
- Build
- None
This compares Semantic Versioning precedence only. Build metadata after + is intentionally ignored when deciding which version has higher precedence. It does not evaluate package-manager ranges such as ^1.2.3 or ~1.2.3.
About This Tool
Version strings cannot be compared reliably as ordinary text. Semantic Versioning gives major, minor, and patch numbers a numeric precedence and defines special rules for prerelease identifiers. This comparator validates complete SemVer values and applies those precedence rules so developers can check release ordering, troubleshoot prerelease tags, or verify which of two versions should sort first.
How To Use It
- Enter two complete semantic versions in major.minor.patch form.
- Add prerelease identifiers after a hyphen or build metadata after a plus sign when they are part of the versions you need to compare.
- Read the comparison symbol and precedence explanation, then inspect the parsed core, prerelease, and build sections.
- Use Swap to reverse the comparison or load the prerelease example to see identifier ordering in action.
Examples
Patch release
1.2.4 has higher precedence than 1.2.3 because major and minor are equal and patch 4 is greater than patch 3.
Prerelease versus release
2.0.0-rc.1 has lower precedence than 2.0.0. A normal version always has higher precedence than a prerelease with the same core version.
Numeric prerelease identifiers
1.0.0-beta.11 has higher precedence than 1.0.0-beta.2 because numeric prerelease identifiers are compared numerically rather than as text.
Build metadata
1.0.0+build.7 and 1.0.0+build.9 have equal SemVer precedence because build metadata is ignored when determining precedence.
Useful Notes
Core version precedence
Semantic versions begin with MAJOR.MINOR.PATCH. These identifiers are non-negative integers without leading zeroes and are compared numerically from left to right: major first, then minor, then patch.
How prerelease identifiers are ordered
A prerelease follows a hyphen and contains dot-separated identifiers. Numeric identifiers compare numerically, numeric identifiers have lower precedence than non-numeric identifiers, and non-numeric identifiers compare lexically using ASCII ordering. If all compared identifiers match, a longer prerelease list has higher precedence than the shorter list.
Why prereleases sort before releases
When two versions have the same major, minor, and patch values, the version with a prerelease suffix has lower precedence. For example, 3.0.0-beta is before the final 3.0.0 release.
Build metadata does not affect precedence
Identifiers after a plus sign describe build metadata. They can distinguish artifacts or build information, but Semantic Versioning explicitly excludes them from precedence comparison. Two versions that differ only in build metadata therefore compare as equal precedence.
Scope: versions, not dependency ranges
This tool compares concrete semantic versions. Expressions such as ^1.2.3, ~2.0.0, >=1.5.0, wildcards, and package-manager-specific range rules are a separate problem and are intentionally not interpreted here.
FAQ
Does 1.10.0 come after 1.9.0?
Yes. Minor identifiers are integers, so 10 is greater than 9. Comparing the strings lexically would give the wrong result.
Is 1.0.0-alpha lower than 1.0.0?
Yes. A prerelease version has lower precedence than a normal version with the same major, minor, and patch values.
Do build numbers after + make a version newer?
Not in SemVer precedence. Build metadata is ignored when comparing precedence, even when its identifiers contain numbers.
Why is 1.0.0-01 rejected?
Numeric prerelease identifiers must not contain leading zeroes under Semantic Versioning. The identifier 0 is valid, but 00 or 01 is not.
Can I compare npm ranges such as ^1.2.3?
No. This tool deliberately compares concrete Semantic Versioning values only and does not implement npm, Cargo, Composer, or other dependency-range dialects.
Related Tools
JSON Formatter & Validator
PopularValidate JSON, pretty-print it, minify it, and inspect JSON paths.
Cron Expression Explainer
Understand each field in a five-field cron schedule.
JWT Decoder
Inspect JWT header, payload, and time claims locally.
UTF-8 Byte Counter
Count UTF-8 bytes, Unicode code points, and UTF-16 code units.