How to use the semver tools
- Type Version A, for example the version you have installed.
- Optionally type Version B to compare. Leave it empty to check A alone.
- Type a Range in npm syntax:
^1.2.0,~1.4,>=1.0.0 <2,1.x,1.2.3 - 2.0.0, or several joined with||. - Set Prerelease identifier for bumps, such as
rc,betaoralpha. - Read the comparison, what the range means, whether each version satisfies it, the parsed parts and the bump table.
What it does and when to use it
Version numbers drive dependency installs, release tooling and update checks, and small details matter: is 1.0.0-alpha.10 newer than 1.0.0-alpha.9? Will ^0.3.1 pull in 0.4.0? Use this page when a lockfile picks a version you did not expect, when you write a peer-dependency range, or when you decide the next release number.
For writing the changelog commit that goes with a release, the Conventional Commit Generator helps, and the Git Cheatsheet lists the git tag commands.
How it works
Versions are checked against the SemVer 2.0.0 grammar: three numbers without leading zeros, an optional -prerelease and an optional +build. Precedence follows section 11 of the spec. Numbers compare numerically, a version with a prerelease is lower than the same version without one, and prerelease parts compare one by one, with numeric parts lower than text parts.
Ranges are expanded the way npm’s node-semver does, into sets of comparators joined by ||. The tool reimplements those rules rather than loading the npm package, and runs in your browser.
Worked examples
A 0.x caret range. A 0.3.7, B 0.4.0, range ^0.3.1:
Comparison: 0.3.7 < 0.4.0
Range ^0.3.1 means: >=0.3.1 <0.4.0-0
0.3.7 | yes
0.4.0 | no
A prerelease and a plain range. A 2.1.0-beta.2, B 2.1.0, range >=2.0.0, identifier beta. The result is 2.1.0-beta.2 < 2.1.0; the beta shows 2.1.0-beta.2 | no and the release yes. The bump table gives prerelease | 2.1.0-beta.3, while minor and patch both give 2.1.0, because releasing a prerelease drops the tag.
An invalid version. A 1.4 returns: “all three numbers are required (MAJOR.MINOR.PATCH)”. Ranges accept partial versions like 1.4; exact versions do not.
Limits and tips
- npm options such as
includePrereleaseand loose parsing are not available. - Only SemVer is understood. Python (PEP 440), Maven and calendar versions follow other rules.
- To compare two
package.jsonfiles line by line, use the Diff Checker.
Frequently asked questions
What is the difference between ^ and ~?
Why does ^0.3.1 stop before 0.4.0?
Why does a beta version fail a range it seems to be inside?
Is v1.2.3 valid?
Does build metadata change the order?
How do we know nothing is uploaded? Test it yourself on the privacy proof page.