Wildcard Ranges (x, *, 1.x, 1.2.*)

Use wildcard characters (x, *, or omitted parts) to match any version within a major or minor line. 1.x equals >=1.0.0 <2.0.0.

Wildcard Ranges

Detailed Explanation

Wildcard (X-Range) Syntax

Wildcards let you express "any version matching this pattern" using x, X, *, or simply by omitting version components.

Syntax Variations

All of these are equivalent ways to express the same range:

Pattern Equivalent Expanded
* (any) >=0.0.0
1.x 1.* >=1.0.0 <2.0.0
1.2.x 1.2.* >=1.2.0 <1.3.0
1 1.x.x >=1.0.0 <2.0.0
1.2 1.2.x >=1.2.0 <1.3.0

How It Works

The x or * character means "any value in this position." The range becomes:

  • Floor: Replace wildcards with 0
  • Ceiling: Increment the component before the first wildcard

Comparison with Other Operators

Range Wildcard Caret Tilde
>=1.0.0 <2.0.0 1.x ^1.0.0
>=1.2.0 <1.3.0 1.2.x ~1.2.0
>=0.0.0 *

When to Use Wildcards

Wildcards are most readable in:

  1. Peer dependencies: "react": "18.x" — clearly "any React 18"
  2. Engine requirements: "node": "20.x" — any Node 20 release
  3. Monorepo workspace ranges: Quick way to say "same major"

The Star (*) Pattern

A bare * means "any version at all." This is rarely used in production dependencies but appears in:

  • Development tool configurations
  • Template package.json files
  • Integration testing setups where version does not matter

Use Case

Expressing broad compatibility requirements in peer dependencies, engine constraints, or workspace configurations where any version within a major line is acceptable.

Try It — Semver Calculator

Open full tool