SemVer Ranges Decoded: Caret, Tilde, Pre-releases and Precedence
What ^, ~, x and hyphen ranges really allow, why pre-releases are skipped, how versions are ordered, and how to test ranges against real version lists.

A single character in a dependency range decides which code ends up in your build. ^1.4.0 and ~1.4.0 look almost identical and behave very differently, and the rules for pre-releases surprise even experienced developers. This guide walks through Semantic Versioning, the npm range syntax and the ordering rules, and shows how to test them with the SemVer Range Checker and Version Comparator.
The version number
A semantic version has three numbers, major.minor.patch, with optional extras. A pre-release tag follows a hyphen, as in 2.0.0-rc.1. Build metadata follows a plus sign, as in 2.0.0+build.7. The meaning is a promise from the maintainer: increase major for incompatible API changes, minor for backward-compatible features, and patch for backward-compatible fixes. Versions below 1.0.0 make no stability promise at all.
The specification is strict about format. Numbers may not have leading zeros, all three parts are required, and identifiers use only letters, digits and hyphens. The checker marks anything else as invalid, which is useful when cleaning up tags in a repository.
Ranges in plain words
- Caret allows changes that do not touch the left-most non-zero number. ^1.4.0 means at least 1.4.0 and below 2.0.0. ^0.4.0 means below 0.5.0, and ^0.0.4 means only 0.0.4, because at zero-major every minor bump may break things.
- Tilde allows patch changes when a minor version is given. ~1.4.2 means at least 1.4.2 and below 1.5.0.
- x and asterisk are wildcards. 1.4.x is any 1.4 patch, and an asterisk alone is any version.
- Hyphen ranges are inclusive. 1.2.3 - 2.3 means at least 1.2.3 and below 2.4.0, because a partial upper bound covers its whole minor line.
- Comparators such as >=, <, > and <= can be combined with spaces for AND and double bars for OR.
The checker rewrites any range into plain comparators, so you can read exactly what it allows before you commit it.
Why pre-releases are skipped
A range like >=1.0.0 does not match 2.0.0-rc.1 in npm, even though it sorts above 1.0.0. The rule is that a pre-release only matches when some comparator in the same group names the same major, minor and patch with a pre-release tag. This keeps unstable builds out of normal installs. The checker explains when this rule excluded a version, and a switch turns it off to mimic npm's include-prerelease option.
How versions are ordered
Comparison runs left to right. Major, minor and patch compare numerically, so 1.10.0 is newer than 1.9.0. A pre-release is always older than the plain release with the same numbers. Pre-release identifiers then compare piece by piece: numbers numerically, words alphabetically by ASCII, and numbers before words. That is why beta.11 is newer than beta.2 and rc.1 is newer than beta.11. Build metadata never affects order.
The compare tab shows the result for any two versions and names the rule that decided, which is handy when a release script picks an unexpected latest version.
Working through a real list
Paste the versions published for a package, one per line, and type the range from your manifest. Each version is marked match, no or invalid, and the highest match is shown. That is the version npm would install if those were the only ones available. For a range of ^1.4.0 || ~2.1.3 against ten versions, the checker shows that 2.1.9 wins, that 2.2.0 is outside the tilde, and that 1.4.0-beta.2 is excluded by the pre-release rule.
Planning the next release
The bump tab takes your current version and a pre-release word such as rc or beta and lists the next major, minor, patch and the pre-release variants. Bumping a pre-release with the same word increments its counter, and bumping a pre-release to its plain release simply drops the tag.
Other ecosystems
Cargo reads a bare version as a caret range; a switch in the tool reproduces that. Python's PEP 440, Maven ranges and Go modules follow different rules and are not modelled here.
Limits
The tool does not query package registries. It works on the versions you paste, so check the registry for the current list before relying on a result.



