deftools.io Developer Tools

SemVer Calculator

Parse, validate, and compare semantic versions (semver). Bump major/minor/patch, test range constraints (^ ~ > x-range), diff versions, and inspect pre-release precedence.

Try an example
Copied!

About this tool

A semantic versioning (SemVer) calculator for working with MAJOR.MINOR.PATCH version strings as defined by semver.org. It parses versions, validates them, compares two versions, tests whether versions satisfy npm range constraints, and bumps versions following the spec.

Inspect breaks a version like 2.4.1-beta.2+build.7 into major, minor, patch, pre-release, and build metadata. Compare shows whether 1.2.0 is less than, equal to, or greater than 2.0.0-rc.1 (the release always wins over a pre-release). Range checks whether versions satisfy a constraint such as ^1.2.0 or >=2.0.0 <3.0.0. Bump produces the next version for a given release type — e.g. 2.4.13.0.0 for a major bump, → 2.5.0 for minor, → 2.4.2 for patch.

Useful before publishing an npm package, checking whether a dependency update is safe, or resolving a ^/~ range in a package.json.

FAQ

What is the difference between ^ and ~?

The caret ^ allows changes that do not modify the left-most non-zero digit: ^1.2.3 allows any 1.x.x ≥ 1.2.3 but blocks 2.0.0. The tilde ~ only allows patch-level changes when the minor is specified: ~1.2.3 allows 1.2.x but blocks 1.3.0. For 0.x versions both behave more conservatively.

Does a pre-release version satisfy a caret range?

Only if the pre-release identifier shares the same [major, minor, patch] tuple as the range lower bound. So 1.5.0-beta satisfies ^1.5.0, but 1.5.0-beta does not satisfy ^1.4.0. This is the npm-strict behavior the tool follows.

Is build metadata considered in comparisons?

No. Per the SemVer spec, build metadata (the part after +) is ignored when determining precedence. 1.0.0+exp.sha.5114f85 equals 1.0.0+build.123 for ordering purposes.

Why does 1.0.0 come after 1.0.0-rc.1?

The SemVer spec states that a version with a pre-release has lower precedence than the corresponding normal version. This prevents a release candidate from being treated as newer than the final release.

More developer tools

Copied!