跳到主要内容

Semver Checker & Validator

Validate a version

Check a version and read its major, minor, patch, prerelease, and build.

Examples

Valid
1.2.3-beta.1
Major
1
Minor
2
Patch
3
Prerelease
beta.1
Build
exp.sha

Compare versions

See which version is greater and which part differs.

Less
1.2.0 is less than 1.10.0

First difference: minor

Version vs range

Test whether a version satisfies an npm range.

Off matches npm: 1.2.4-beta.1 does not satisfy ^1.2.3.

Does not satisfy
1.2.4-beta.1 does not satisfy >=1.2.3 <2.0.0-0

Range explorer

Expand ^, ~, x, and other npm range syntax.

>=1.2.3 <2.0.0-0

Most common version numbers (clickable)

semver

Semantic Version, consisting of three parts, MAJOR.MINOR.PATCH.

MAJORWhen releasing API with Breaking Changes
MINORWhen releasing new feature APIs
PATCHWhen fixing bugs
^1.2.3>=1.2.3 <2.0.0
~1.2.3>=1.2.3 <1.3.0

Semantic Versioning (Semver)

semver, short for Semantic Versioning, is a versioning convention documented at semver.org. This page is a semver checker and validator: paste a version to see whether it is valid, compare two versions, and test a version against an npm range. Precedence follows Semantic Versioning 2.0.0. Operators such as ^ and ~ come from the npm semver range syntax, not from the semver specification itself. A version number consists of three parts: [major, minor, patch], where:

  • major: incremented when you make incompatible API changes (Breaking Changes)
  • minor: incremented when you add functionality in a backward-compatible manner
  • patch: incremented when you make backward-compatible bug fixes

For ~1.2.3, the matched version range is >=1.2.3 <1.3.0

For ^1.2.3, the matched version range is >=1.2.3 <2.0.0

npm packages use semver for version management. When you install lodash and the latest version is lodash@4.17.4, npm will save lodash@^4.17.4 in your package.json by default.