Comparison Operators (>=, >, <, <=, =) in Semver Ranges

Use comparison operators like >=1.0.0, <2.0.0, >1.5.0, and =1.2.3 in semver ranges. Combine them to create precise version bounds.

Comparison Operators

Detailed Explanation

Comparison Operators in Semver

Comparison operators give you explicit control over version bounds, unlike the shorthand of caret or tilde.

Available Operators

Operator Meaning Example
>= Greater than or equal >=1.0.0
> Greater than (strict) >1.0.0
<= Less than or equal <=2.0.0
< Less than (strict) <2.0.0
= Exactly equal =1.2.3

Combining Operators

Multiple operators in the same string (separated by spaces) form an AND condition — the version must satisfy all of them:

>=1.0.0 <2.0.0

This means "1.x.x" — any version from 1.0.0 up to (but not including) 2.0.0. This is equivalent to ^1.0.0.

Common Patterns

Pattern Equivalent Use Case
>=1.0.0 <2.0.0 ^1.0.0 Compatible with v1
>=1.2.0 <1.3.0 ~1.2.0 Patch updates of 1.2
>=1.0.0 <1.0.0 (nothing) Impossible range
>=0.0.0 * Any version

Strict vs Inclusive

The difference between > and >= matters:

  • >=1.0.0 — includes 1.0.0 itself
  • >1.0.0 — starts from the first version after 1.0.0 (e.g., 1.0.1)

Similarly:

  • <=2.0.0 — includes 2.0.0 itself
  • <2.0.0 — stops at the last version before 2.0.0 (e.g., 1.99.99)

Real-World Usage

Comparison operators are common in:

  • Engine constraints: "node": ">=18.0.0"
  • Peer dependencies: "react": ">=16.8.0 <19.0.0"
  • Custom ranges: When caret/tilde do not express what you need

Use Case

Specifying engine requirements in package.json (e.g., Node.js version), or creating custom dependency ranges that don't fit the caret/tilde shorthand.

Try It — Semver Calculator

Open full tool