Semver Comparator and Range Explainer

Compare semantic versions, sort them with the specification's prerelease rules, and test each one against a range.

Inputs stay on your device No sign-up Free to use
How this works

The tool runs in this browser. Your file or text is not uploaded to UseFreeTools. Check this tool's limits for anything it may save on your device.

Privacy details

Compare versions controls

One version per line, such as 1.2.3. The lines are sorted and each one keeps its place in the order.

For example ^1.2.0, ~1.2.3, >=1.2 <2.0.0 or 1.x. Leave it empty to see the order only.

Off by default, which follows the specification: a prerelease is only in range when the range itself names a prerelease with the same major, minor and patch.

Processed in your browser. Your inputs stay on this device.

Showing a generated example. Generate again for a new result.

How to use Semver Comparator and Range Explainer

  1. List the versions to compare, one per line.
  2. Optionally type a range to test them against, such as ^1.2.0, ~1.2.3, >=1.2 <2.0.0 or 1.x.
  3. Press Compare versions and read the sorted order with the prerelease and build parts of each one.
  4. 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.

You add
Versions to compare: 1.2.3, 1.9.0 and 1.3.0-rc.1 listed on three lines. Range to test against: ^1.2.0. Let prereleases match the range: off.
You get
The order is 1.2.3, then 1.3.0-rc.1, then 1.9.0. The range is stored as >=1.2.0 <2.0.0-0, 1.2.3 and 1.9.0 are in range, and 1.3.0-rc.1 is out with the reason that a prerelease only matches when the range itself names one with the same major, minor and patch.

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

Up to 200 versions in one comparison, at most 5,000 lines and 200,000 characters of input. A line that is not a valid semantic version is refused and named by its line number rather than being skipped. A range is limited to 200 characters, and parsing and matching come from the semver package so the ordering follows the specification rather than a private rule. Also note that a range is a comparison of version numbers only; it says nothing about whether a release exists, is published or is compatible with your code.

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.

Project manager: Tony Hines · Content updated 1 October 2026 · Report a problem