Semantic versioning in one minute
SemVer is MAJOR.MINOR.PATCH: bump MAJOR for breaking changes, MINOR for backward-compatible features, PATCH for bug fixes. Pre-release tags (-beta.2, -rc.1) sort before the final release. Comparison is numeric, segment by segment, left to right — 2.10.0 > 2.9.9 because 10 > 9, never string order.
Range operators
- Exact
1.2.3— only that version. - Caret
^1.2.3— compatible: <2.0.0 for a 1.x (allows 1.9.9, blocks 2.0.0).^0.2.3stays <0.3.0. - Tilde
~1.2.3— patch-level: <1.3.0.~1.2is the same as~1.2.0. - Wildcards
1.2.x,1.*— any matching segment. - Comparators
>=1.0.0 <2.0.0— explicit bounds. - OR
||— either range matches.
Why it matters
Lockfiles and package managers resolve ranges every install. Knowing what ^ actually allows — and that ^0.x behaves like ~0.x — prevents surprise upgrades (or missing security patches) in your dependencies.
Formats, sizes and other limits
parseVer() splits a version into major, minor and patch numbers, an optional pre-release tag and build metadata using one anchored regular expression, so a malformed version is rejected rather than half-understood. compare() then compares numerically field by field and, when the numeric parts tie, falls back to pre-release rules — a version with a pre-release tag sorts before the same version without one. verMatchesRange() splits on || for alternatives, treats whitespace between comparators as AND, and singleMatch() applies one comparator such as caret, tilde, or a bare version.
Where it stops working
The range grammar implemented here is the common subset, not npm's full resolver: aliases such as npm:, file: and git+ URLs, workspace protocols and dist-tags are not understood, and || combined with hyphen ranges can differ from what npm decides. Pre-release matching is the other soft spot — npm only considers pre-releases when the range itself mentions one, and a reimplementation can drift on that detail.
Privacy: nothing is uploaded
Version strings are compared with local string and number operations. No registry is queried, so the page cannot leak which packages you are investigating.
Frequently asked questions
Does ^1.2.3 include 2.0.0?
No. A caret range allows changes that do not modify the left-most non-zero digit, so ^1.2.3 stays below 2.0.0 but accepts 1.9.9.
Why does npm resolve differently?
Because npm's resolver supports aliases, workspace protocols and dist-tags that this page does not parse. For a lockfile-level answer, ask npm.
How do pre-release versions sort?
A pre-release sorts before its release: 1.0.0-rc.1 is lower than 1.0.0. Numeric identifiers compare numerically, alphanumeric ones lexically.