Skip to content

Semver Comparator

Compare two semantic versions and test them against a range.

Caret, tilde, x-ranges, hyphen ranges, comparator sets and || unions are all understood.

Quick Tool Overview

The Semver Comparator compares two versions and tests them against a range, with the two rules that cause most of the surprises implemented properly — caret tightening below 1.0.0, and a prerelease only matching a range that already mentions one.

What it does
Compares versions and evaluates ranges
You give it
Two versions, and optionally a range
You get back
Which is higher, what changed, and what the range allows
Best for
Working out what a dependency range really permits
Developer Tools Free, unlimited use No sign-up Runs in your browser

About the Semver Comparator

Compare two semantic versions, see which is higher and which part changed, and test whether a version satisfies a range — caret, tilde, x-ranges, hyphen ranges, comparator sets and unions all behave the way npm makes them behave.

Two rules cause most of the surprises. Below 1.0.0, a caret range tightens: `^0.2.3` allows 0.2.9 but not 0.3.0, because in a zero-major package the minor is treated as the breaking number. And a prerelease only satisfies a range that already mentions a prerelease on the same major.minor.patch — which is why `^1.0.0` does not match 2.0.0-rc.1 even though 2.0.0-rc.1 sorts below 2.0.0. Both are implemented here, along with the ordering rule that numeric prerelease identifiers compare numerically, so beta.11 correctly outranks beta.2.

Key features of the Semver Comparator

Zero-major caret handled

^0.2.3 allows 0.2.9 but not 0.3.0, because below 1.0.0 the minor is treated as the breaking number. This is the rule most implementations get wrong.

Prerelease matching by the specification

^1.0.0 does not match 2.0.0-rc.1, so an untested release candidate is never installed just because it sorts below a version you allowed.

Correct prerelease ordering

Numeric identifiers compare numerically, so beta.11 outranks beta.2 rather than sorting below it as a string would.

Every range syntax

Caret, tilde, x-ranges, hyphen ranges, comparator sets and || unions, with the bounds each expands to shown.

The next version too

What a major, minor, patch or prerelease bump would produce from where you are.

How to use the Semver Comparator

  1. 1

    Enter two versions

    Any two semantic versions, with or without a leading v.

  2. 2

    Read the comparison

    Which is higher, and whether the difference is major, minor, patch or prerelease.

  3. 3

    Test a range

    Enter something like ^1.2.3 or >=2 <3 to see whether the version satisfies it, and what the range expands to.

  4. 4

    Check the next version

    The result shows what a major, minor, patch or prerelease bump would produce.

Frequently asked questions

A caret allows anything up to the next major: ^1.2.3 covers 1.9.0. A tilde allows only patch changes: ~1.2.3 stops before 1.3.0. Caret is npm’s default because minor releases are supposed to be backwards compatible.

Reviews of the Semver Comparator

What people who use the Semver Comparator think of it. Reviews come from visitors and are posted as written.

No ratings yet

Yours would be the first.

  • 5 0 reviews rated 5 stars
  • 4 0 reviews rated 4 stars
  • 3 0 reviews rated 3 stars
  • 2 0 reviews rated 2 stars
  • 1 0 reviews rated 1 star

Write a review

Used this tool? Your rating helps the next person decide.

Your rating

Plain text only — links, email addresses and HTML are not accepted. Your name and review are shown publicly; nothing else is collected. See the privacy policy.

0 reviews

Newest first

No reviews yet

Be the first to rate the Semver Comparator. It takes half a minute and no account.

Write the first review

More developer tools