Semver Version Sorter
Sort a list of version numbers by Semantic Versioning precedence (1.10.0 after 1.9.12, betas before releases), dedupe them, and see the next major, minor, patch and pre-release.
Free · No sign-up · Your inputs stay in your browser
Input
Sort version numbers by semver
Output
Latest: 2.0.0
Sorted
2.0.0 2.0.0-alpha v1.10.0 v1.9.12 v1.2.0 1.2.0-rc.1 1.2.0-beta.11 1.2.0-beta.2
Not semver: release-candidate
| Next major | 3.0.0 |
|---|---|
| Next minor | 2.1.0 |
| Next patch | 2.0.1 |
| Next prerelease | 2.0.1-rc.0 |
Semantic Versioning 2.0.0 order: numbers compare numerically (1.10.0 is newer than 1.9.12, which a plain text sort gets wrong), a pre-release sorts before its release, and pre-release identifiers compare numerically when they are numbers, so beta.11 comes after beta.2. Build metadata after + is ignored. sort -V in GNU coreutils gets most of this right too.
Runs in this browser. Nothing you paste is sent to a server.
About this tool
Method, assumptions, practical next steps, and limits.
Why text sorting fails
Sorted as text, 1.10.0 comes before 1.9.0 and beta.11 before beta.2. SemVer compares numeric parts as numbers, puts a pre-release before its release, compares pre-release identifiers numerically when they are numbers, and ignores build metadata, as the specification's precedence rules define.
Tags in Git
git tag --sort=-v:refname sorts tags by version, and GNU sort -V gets most cases right, though both treat pre-releases differently from SemVer in some edge cases.