How to use Semver Comparator and Range Explainer
- List the versions to compare, one per line.
- Optionally type a range to test them against, such as ^1.2.0, ~1.2.3, >=1.2 <2.0.0 or 1.x.
- Press Compare versions and read the sorted order with the prerelease and build parts of each one.
- Read the range line to see the comparator set the range is stored as, and the reason column for any version left outside it.
Example: Semver Comparator and Range Explainer
Sort three versions and test them against a caret range.
Options
- The comparator set
- A range is stored as comparators joined by AND, with alternatives joined by ||. ^1.2.0 is stored as >=1.2.0 <2.0.0-0, and 1.x || >=3 is stored as two sets, so a version passes when either one matches.
- Prereleases
- A prerelease sorts before the release it leads to, so 1.0.0-rc.1 is lower than 1.0.0. A range leaves prereleases out unless it names a prerelease with the same major, minor and patch, which the Why not column reports per version.
- Build metadata
- A build suffix such as +build.2 is shown in its own column and is ignored when two versions are ranked, exactly as the specification says.
Supported inputs and limits
Where your input is processed
This tool processes your input in this browser. Your text and files are not uploaded to UseFreeTools. Check this tool's limits for anything it may save on your device.
Reading a range as sets rather than one line
A range with || is a list of alternatives. Each alternative is a group of comparators that must all hold, and the groups themselves are tried one after another. Keeping the groups separate is what makes 1.x || >=3 readable, because a version only has to satisfy one group rather than every comparator in the line.
Questions about Semver Comparator and Range Explainer
Why is a release candidate lower than the release?
The specification puts a prerelease before the version it leads to, so 1.0.0-rc.1 ranks below 1.0.0. That is also why a range leaves prereleases out unless it names one.
Why is 1.10.0 above 1.9.0?
Each part is compared as a number rather than as text, so the minor version 10 is above the minor version 9. Text sorting would put 1.10.0 first, which is the mistake this comparison avoids.
Is a two-part version such as 1.2 accepted?
No. A semantic version needs major, minor and patch, so 1.2 is reported by its line number and the message says what a version looks like.
What does the -0 in an upper bound mean?
It is how the range excludes prereleases of the next version. The bound <2.0.0-0 is lower than any 2.0.0 prerelease, so a version such as 2.0.0-rc.1 stays outside a caret range that starts at 1.