Developer Utilities

SemVer Comparator

Strictly validate, compare, and sort Semantic Versioning 2.0.0 versions.

SemVer 2.0.0
Strict validation and precedence comparison, including prerelease identifiers.
Version B has higher precedence
VersionMajorMinorPatchPrereleaseBuild
1.8.0-beta.2180beta.2
1.8.0180
Sort a version list
One version per line; invalid entries are excluded from the result.
Sorted result
2.0.0 2.0.0-rc.1 1.8.0 1.8.0-beta.2 1.7.12

SemVer Comparison

Strictly validate, compare, and sort Semantic Versioning 2.0.0 versions, including numeric and alphanumeric prerelease identifiers.

Precedence

  • Major, minor, and patch are compared in order
  • A release has higher precedence than a prerelease with the same core version
  • Build metadata does not affect precedence

Frequently Asked Questions

What is the difference between ^ and ~ in semver?
~1.2.3 allows patch changes (>=1.2.3 <1.3.0); ^1.2.3 allows minor and below (>=1.2.3 <2.0.0). For 0.x versions ^0.2.3 only allows patches — during 0.x the minor acts as the breaking-change slot. npm saves ^ by default.
Does a prerelease (1.0.0-beta.1) outrank the release?
No: 1.0.0 outranks every 1.0.0-x prerelease. Prerelease identifiers compare lexicographically (alpha < beta < rc). Build metadata (+build.1) does not affect precedence at all — 1.0.0+a equals 1.0.0+b, a common misconception when deciding whether to republish.
When should I bump the major version?
Whenever existing users can break: removed or re-signatured exports, behavior changes, raised environment requirements. When unsure whether a change is breaking, treat it as breaking — semver’s value is trustworthy upgrades, and an accidental minor bump costs far more than an extra major.