Semver range tester

What is a Semver Range Tester?

Semantic versioning (semver) numbers releases as MAJOR.MINOR.PATCH, and package managers such as npm, pnpm, Yarn and Composer use ranges to decide which versions of a dependency can be installed. Ranges like ^1.2.3 and ~1.2.3 look similar but allow very different updates. This tester checks whether specific versions satisfy a range and compares versions.

How to use it

  1. Enter a range, for example ^4.17.0.
  2. Enter one or more versions to test.
  3. See which versions satisfy the range, and compare versions to see which is newer.

Range syntax

  • Caret ^1.2.3: allows changes that do not modify the left-most non-zero digit: >=1.2.3 <2.0.0. For ^0.2.3 it means >=0.2.3 <0.3.0.
  • Tilde ~1.2.3: allows patch updates: >=1.2.3 <1.3.0.
  • Comparators: >=1.0.0 <2.0.0, combined with spaces (AND) or || (OR).
  • X-ranges: 1.x or 1.2.*.
  • Hyphen: 1.2.3 - 2.3.4 means inclusive bounds.

Examples

  • ^1.2.3 matches 1.2.3, 1.9.0 and 1.99.99, but not 2.0.0.
  • ~1.2.3 matches 1.2.9 but not 1.3.0.
  • ^1.2.3 does not match 1.3.0-beta.1: prerelease versions only match if the range itself includes a prerelease on the same version.

Tips

  • Version 0.x packages may break on minor releases, which is why caret is stricter for them.
  • Lock files (package-lock.json, pnpm-lock.yaml) pin exact versions; ranges matter when the lock file is updated.
  • Run npm outdated to see which updates your ranges allow.

Frequently Asked Questions

What is the difference between caret and tilde?

Caret allows minor and patch updates within the same major version. Tilde allows only patch updates within the same minor version.

Why does ^0.2.3 not allow 0.3.0?

For 0.x versions, the minor number is treated as breaking, so the caret only allows patch updates.

Why is a beta version not matched by my range?

Prereleases are excluded unless the range includes a prerelease tag on the same major, minor and patch version.

What does semantic versioning mean?

MAJOR changes break compatibility, MINOR adds backward-compatible features and PATCH fixes bugs.