Advertisement
Guide
About the Semver Range Calculator
Semantic versioning numbers releases MAJOR.MINOR.PATCH: a major bump may break things, a minor one adds features, a patch fixes bugs. Dependency ranges in package.json use that meaning to accept safe updates automatically.
Type any range to see what it really allows. Matching follows the same grammar as npm, so the results match what npm install would accept.
Caret (^) versus tilde (~)
^1.2.3allows anything up to the next major version (<2.0.0): new features and fixes. ~1.2.3allows only patches (<1.3.0). Below 1.0.0 the caret is stricter: ^0.2.3means <0.3.0, because in 0.x versions every minor release may break things.
Prereleases are opt-in
A version like 2.0.0-beta.1 only matches if the range itself mentions a prerelease of the same version. That is why ^1.2.3 never installs a beta of 2.0.0, and >=2.0.0-beta.0 accepts 2.0.0 betas but not 2.1.0 betas.
How to use it
- 1Type a range or pick an example.
- 2Read it spelled out as comparators.
- 3Paste versions or load them from npm.
- 4See which versions match and which one npm would install.
Frequently asked questions
What does ^ mean in package.json?
The caret accepts updates that do not change the leftmost non-zero number. ^1.2.3 allows 1.x.x from 1.2.3 up; ^0.2.3 allows 0.2.x from 0.2.3 up.
What does ~ mean in package.json?
The tilde allows patch updates when a minor version is given: ~1.2.3 means >=1.2.3 <1.3.0. ~1 means any 1.x.x.
What does 1.x or 1.* mean?
Any version with major 1: >=1.0.0 <2.0.0. A bare 1.2 is the same as 1.2.x.
Which version will npm install?
The highest published version that satisfies the range, unless a lockfile pins a different one. npm ci always installs exactly what the lockfile says.
Should I pin exact versions?
Applications often rely on the lockfile and keep ^ ranges. Libraries should use ranges so users can share a single copy of a dependency.
