Semver Range Checker
What ^1.2.3 or ~1.2 means in plain words, and which versions it allows.
Range forms
- Caret ranges (^1.2.3)
- Tilde ranges (~1.2.3)
- Caret ranges below 1.0 (^0.2.3)
- X-ranges (1.x and 1.2.*)
- Hyphen ranges (1.2.3 - 2.3.4)
- Comparators (>=1.2.0 <2.0.0)
- OR ranges (^1.0.0 || ^2.0.0)
- Pre-release versions (1.0.0-beta.1)
Questions
What is the difference between ^ and ~?
^1.2.3 allows any 1.x.x from 1.2.3 up, so new features but not 2.0.0. ~1.2.3 allows only 1.2.x from 1.2.3 up, so bug fixes only. npm uses ^ by default.
Why does ^0.2.3 not allow 0.3.0?
Below 1.0.0, the first non-zero number is treated as the major version, because any 0.x release may break things. So ^0.2.3 means below 0.3.0, and ^0.0.3 means exactly 0.0.3 up to below 0.0.4.
Why is 1.3.0-beta.1 not matched by ^1.2.3?
npm only allows a pre-release if the range names a pre-release of the same version, like ^1.3.0-beta.0. This stops you getting unstable versions by accident.
Which range syntax is supported?
The same as npm: ^ and ~, x and * wildcards (1.x, 1.2.*), partial versions (1.2), hyphen ranges (1.2.3 - 2.3.4), comparators (>=, <, and so on), spaces for AND and || for OR.
Does build metadata like +build.5 matter?
No. Build metadata after a + is ignored when comparing versions, as the SemVer spec says.
Related tools
- JSON Formatter & ValidatorFormat, minify, check and repair JSON, with errors shown by line and column.
- Cron Expression ParserAny cron expression in plain English, with its next five run times.
- Regex TesterTest a regex against your text, with live highlights and a replace preview.
- Chmod CalculatorUnix permissions as octal (755) and letters (rwxr-xr-x), with what each one allows.