All tools

Semver Compare & Range

Compare two versions and test against a range.

Compare two versions

1.4.2 < 1.5.0

Satisfies a range?

2.3.4 satisfies ^2.0.0

Range syntax

  • ^1.2.3 - 1.x.x (≥1.2.3 <2.0.0)
  • ~1.2.3 - 1.2.x (≥1.2.3 <1.3.0)
  • >=1.0.0 <2.0.0 - explicit range
  • 1.x or 1.* - any 1.x.x
  • 1.0.0 || 2.0.0 - either exact

Semver comparison and range matching, like npm uses for package version constraints. The caret (^) is the npm default - allows non-breaking updates. The tilde (~) is more conservative - only patch updates.

About

Two-version comparison shows whether A is less than, equal to, or greater than B. Range matcher tests whether a version satisfies an npm-style range like ^1.0.0 or ~2.3.0.

How to use

  1. Type two versions.
  2. Or test a version against a range.

FAQ

Caret vs tilde?+

^1.2.3 allows updates that don't change the leftmost non-zero digit (so 1.x.x). ~1.2.3 only allows patch updates (so 1.2.x). Caret is the npm default.