Semver Comparator
Compare, validate, and sort semantic version strings. Check if a version satisfies an npm-style range like ^1.0.0 or >=2.0.0. Free online tool.
Enter two version strings above to compare them.
Related Tools
About Semver Comparator
How It Works
- Enter two semver strings (e.g. 1.2.3 and 2.0.0) to compare them
- Use the range checker to test if a version satisfies an npm-style range
- Paste a list of versions to sort and validate them in bulk
- The parsed view breaks any version into its major, minor, patch, and pre-release parts
Common Use Cases
- Checking whether a dependency update is a major, minor, or patch release
- Validating that a package version satisfies a peer-dependency range
- Sorting release history or changelogs by version
- Learning the semver specification interactively
Frequently Asked Questions
What is semantic versioning (semver)?
Semantic versioning is a versioning scheme where version numbers follow the format MAJOR.MINOR.PATCH. MAJOR increments for breaking changes, MINOR for new backward-compatible features, and PATCH for backward-compatible bug fixes. It is widely used in npm, Cargo, and many other package managers.
How do I compare two version numbers?
Enter both version strings in the Compare tab. The tool will tell you which version is greater, or if they are equal. Comparison follows the semver specification: major is compared first, then minor, then patch, then pre-release identifiers.
What is a semver range?
A semver range is an expression that matches a set of versions. Common range operators include ^ (compatible with), ~ (approximately equivalent to), >=, <=, >, <, and =. Ranges can be combined with spaces (AND) or || (OR). For example, >=1.2.0 <2.0.0 matches all 1.x versions at or above 1.2.0.
What does the ^ (caret) operator mean in semver?
The caret ^ operator matches versions that are compatible with the specified version. For ^1.2.3 it matches >=1.2.3 <2.0.0. For ^0.2.3 it matches >=0.2.3 <0.3.0. For ^0.0.3 it matches only 0.0.3. It is the default range operator used by npm.
What does the ~ (tilde) operator mean in semver?
The tilde ~ operator matches patch-level changes. ~1.2.3 matches >=1.2.3 <1.3.0. It is more restrictive than caret and is useful when you want to lock to a specific minor version while still allowing patch updates.
How are pre-release versions compared?
Pre-release versions (e.g. 1.0.0-alpha, 1.0.0-beta.1) have lower precedence than the associated normal version. For example, 1.0.0-alpha < 1.0.0. Pre-release identifiers are compared field by field: numeric identifiers are compared as numbers, alphanumeric identifiers are compared lexically.
Does build metadata affect version comparison?
No. Build metadata (the part after +, e.g. 1.0.0+build.1) is ignored during version comparison and precedence calculations per the semver specification. Two versions that differ only in build metadata are considered equal.
How do I sort a list of versions?
Switch to the Sort & Validate tab, paste your version list (one per line), and choose ascending or descending order. The tool will sort all valid semver strings and list any invalid entries separately.
What counts as a valid semver string?
A valid semver string must follow the format MAJOR.MINOR.PATCH where each part is a non-negative integer with no leading zeros. It may optionally include a pre-release suffix (e.g. -alpha.1) and build metadata (e.g. +001).
Is this tool free to use?
Yes, the Semver Comparator is completely free and runs entirely in your browser. No data is sent to a server — all comparisons and validations happen client-side.