Zero Signup ToolsFree browser tools

Developer Tools

Semver Comparator

Compare two semver versions and test npm-style ranges in your browser. Supports caret, tilde, X-ranges, hyphen ranges, and OR.

Semver comparator

Compare two versions

Both inputs use the MAJOR.MINOR.PATCH grammar with optional -pre and +build suffixes.

Try:

Relation

A < B

Version A is older than version B.

compare()-1differenceminor

Version A

1.2.3

Normalized
1.2.3
Major
1
Minor
2
Patch
3
Pre-release
none
Build
none

Version B

1.4.0

Normalized
1.4.0
Major
1
Minor
4
Patch
0
Pre-release
none
Build
none

Next versions from A

Computed using semver inc() rules. Click any value to copy.

  • major2.0.0
  • minor1.3.0
  • patch1.2.4
  • premajor2.0.0-0
  • preminor1.3.0-0
  • prepatch1.2.4-0
  • prerelease1.2.4-0

Does a version satisfy a range?

Supports caret (^), tilde (~), X-ranges (1.x), comparators (>=, >, <=, <, =), hyphen ranges, and || OR.

Try:

Result

Matches

1.5.0 satisfies ^1.2.3

Expanded comparator form

The range is parsed into a disjunction (||) of conjunctions of explicit comparators.

>=1.2.3 <2.0.0

Comparison rules

  • Major, minor, and patch are compared numerically left to right. 1.2.10 is greater than 1.2.3 because 10 > 3.
  • A version with a pre-release tag has lower precedence than the same version without one. 1.0.0-rc.1 is older than 1.0.0.
  • Pre-release identifiers are compared piece by piece. Numeric identifiers compare numerically; alphanumeric ones compare lexically; numeric is always lower than alphanumeric.
  • Build metadata (the part after +) is ignored when comparing. 1.0.0+build.7 and 1.0.0+build.42 are equal in precedence.

Range operators

  • ^1.2.3 matches anything greater than or equal to 1.2.3 and less than 2.0.0. With a zero major, the lock tightens: ^0.2.3 stays in 0.2.x; ^0.0.3 stays at 0.0.3.
  • ~1.2.3 matches anything in 1.2.x at or above 1.2.3.
  • 1.x, 1.*, and 1 all mean 1.0.0 to just before 2.0.0.
  • 1.0.0 - 2.0.0 is a hyphen range, inclusive on both ends.
  • || joins multiple ranges. The version matches if any side matches.
  • Pre-release versions are excluded from ranges unless the range itself names a pre-release at the same major.minor.patch.

How to use

  1. Paste two semver versions into the Version A and Version B inputs. Validation runs as you type, with field-level errors when a part is missing or malformed.
  2. Read the relation block (A < B, A = B, A > B) and which part differs (major, minor, patch, pre-release, or build). Use Swap to flip the inputs or Clear to start over.
  3. In the range section, paste a version and a range expression. The result shows whether the version satisfies the range and prints the expanded comparator form (for example ^1.2.3 expands to >=1.2.3 <2.0.0).
  4. Use the Next versions from A panel to copy the result of a major, minor, patch, premajor, preminor, prepatch, or prerelease bump.
  5. Try the preset chips to see edge cases: numeric vs alphanumeric pre-releases (alpha vs alpha.1), the zero-major caret rule (^0.2.3 stays in 0.2.x), and OR ranges (^1.0.0 || ^2.0.0).

About this tool

Semver Comparator parses two version strings, compares them by the official Semantic Versioning ordering rules, and checks whether a version satisfies an npm-style range, all in your browser. Versions are validated against the MAJOR.MINOR.PATCH grammar with optional pre-release and build suffixes. The comparator follows semver.org precedence: major, minor, and patch compare numerically; a pre-release tag has lower precedence than the same version without one; pre-release identifiers compare one at a time with numeric identifiers ordered before alphanumeric; and build metadata is ignored when comparing. The range engine supports caret (^1.2.3), tilde (~1.2.3), X-ranges (1.x), comparators (>=, >, <=, <, =), hyphen ranges (1.0.0 - 2.0.0), and OR (||), and applies the same pre-release inclusion rules that npm uses, so 1.2.3-beta is excluded from ^1.2.3 unless the range itself names a pre-release on that major.minor.patch. The tool also computes the next major, minor, patch, premajor, preminor, prepatch, and prerelease bumps from version A using semver inc() rules. Parsing, comparison, range expansion, and bumping all run locally; nothing is uploaded.

Free to use. Works in your browser. No signup, no login.

Related tools

You may also like

All tools
All toolsDeveloper Tools