Skip to content
en es

Semver Tool

Compare two semantic versions, check whether a version satisfies an npm or Composer constraint such as ^1.2 or ~2.0, and sort a list of versions correctly (1.10.0 comes after 1.2.0).

Runs in your browser — nothing is uploaded.

Compare two versions

Test a range

For example ^1.2.0, ~1.2, >=1.0 <2.0, 1.x or 1.0 || 2.0.

Let 1.3.0-beta.1 match ^1.2.0.

Sort versions

One per line (commas also work).

Copied

How to use it

  1. To compare, type two versions. You get which is newer and the kind of change (major, minor, patch, pre-release).
  2. To test a range, enter a version and a constraint, and choose npm or Composer.
  3. To sort, paste one version per line and pick the order.

Frequently asked questions

How does semantic versioning order versions?

By major, minor and patch as numbers (1.10.0 is newer than 1.9.0), then a version with a pre-release tag is older than the same version without it (1.0.0-rc.1 is older than 1.0.0). Build metadata after + is ignored.

What do ^ and ~ mean?

^1.2.3 allows changes that do not touch the left-most non-zero number: >=1.2.3 <2.0.0 (^0.2.3 is >=0.2.3 <0.3.0). ~1.2.3 allows patch changes only: >=1.2.3 <1.3.0.

How do Composer constraints differ from npm?

In Composer ~1.2 means >=1.2.0 <2.0.0 (in npm it stops at 1.3.0), a bare 1.0 is exactly 1.0.0, and AND is written with a comma or a space and OR with | or ||. In Composer mode the tool translates the constraint and shows the npm equivalent. Version numbers with four parts, branch names and stability flags other than @dev, @alpha, @beta, @rc and @stable are not supported.

Why does a pre-release not match my range?

By npm’s rule, 1.3.0-beta.1 only satisfies a range if the range itself names a pre-release of the same 1.3.0. Tick “Include pre-releases” to ignore that rule.

Are leading v and extra zeros accepted?

A leading v (v1.2.3) is accepted. Leading zeros (01.2.3) and versions with fewer than three parts (1.2) are not valid semver.