Skip to content
Agents tracked: 492 Releases (7d): 545 Agent status: 1 with issuesSince last limit reset: Claude 9d · Codex 7d For AI agents: Markdown Updated Nov 20, 2026

semver (JavaScript)

Compare and bump version numbers in JavaScript.

UtilitiesNPM

GitHubWebsite

1. License

“Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.”

ISC allows any use, with or without fee.

github.com/npm/node-semver/blob/main/LICENSE

From the package registry and GitHub, checked daily; card checked Nov 10, 2026. Tap a verdict to see its source.How we checkedReport an error

What semver (JavaScript) does

semver is a small free JavaScript library that understands version numbers like 1.4.2 and rules like "1.2 or newer, but not 2". Your app or script can tell which version is newer, whether a version fits a rule, and what the next version number should be. It is the same version logic npm itself uses.

What people build with it

Stop when Node.js is too old

Your setup script checks the installed Node.js version first and stops with a clear message instead of failing later.

Tell users an update is out

Your tool compares its own version with the newest one and says whether the update is a big or a small change.

Pick the newest version that fits

From a list of published versions, choose the highest one that still matches the rule in your settings file.

Work out the next release number

Before you publish, your release script computes the next patch, minor, major or beta number from the current one.

Read versions from messy text

Pull a usable version out of strings like "v3.4 replaces v3.3.1" that other tools print.

Check which plugins fit your app Idea

Each plugin states the app versions it supports; your app loads only the plugins whose rule matches its own version.

semver (JavaScript) popularity

69 / 100
Gid Score, #370 overall
1.19B
downloads a week, npm
5,475
GitHub stars
64
agent projects use it
semver (JavaScript): downloads per weeknpm, semver 1,187,753,782
semver (JavaScript): GitHub starsnpm/node-semver 5,475

Gid Score measures public popularity and activity, not quality. How the Gid Score is calculated

How semver (JavaScript) is used

  • semver (JavaScript) is a dependency in 64 of the 6,254 public GitHub projects set up for AI coding agents that we scanned (1.3% of the 4,863 JavaScript/TypeScript ones), #21 of 406 in utilities.
  • Counting the projects our scan samples by dependency (Solana 3,063, Ethereum and EVM 1,777, 3D and games 3,120, agent frameworks and SDKs 13,629), it appears in 220; those are left out of every share on this page.
  • Projects that use it most often also use Vitest (70.3%), tsx (54.7%), yaml (45.3%).

By coding agent

52 projects, 1.6%
30 projects, 1.0%
21 projects, 0.9%
11 projects, 3.4%
10 projects, 2.2%

Often used with

In 70.3% of its projects
In 54.7% of its projects
In 45.3% of its projects
In 42.2% of its projects
In 42.2% of its projects
In 40.6% of its projects
In 90.6% of its projects

More about semver (JavaScript)

More in Utilities

Alternatives

semver (JavaScript) This page

ISCGid 691.19B/wk

packaging

Pick packaging in Python projects; it parses Python package versions and version rules.

semver (Python)

Pick the Python semver package when you need the same SemVer rules in Python code.

npm-check-updates

Pick npm-check-updates when you only want to find and apply newer versions in package.json, not write code.

Compare semver (JavaScript) with another tool

Get started

Tell your AI assistant

“Use the npm package semver (pin semver@7.8.6, Node.js 10+) for every version comparison in this project: semver.gt/compare instead of string comparison, semver.satisfies for ranges, and semver.inc to compute the next release number.”

  1. Add semver to your project.

    npm install semver

    From github.com/npm/node-semver/blob/main/README.md

  2. Load it and call the function you need.

    const semver = require('semver')
    
    semver.valid('1.2.3') // '1.2.3'
    semver.valid('a.b.c') // null
    semver.satisfies('1.2.3', '1.x || >=2.5.0 || 5.0.0 - 7.2.3') // true
    semver.gt('1.2.3', '9.8.7') // false
    

    From github.com/npm/node-semver/blob/main/README.md

Mistakes to avoid

if (latest > current) with version strings
semver.gt(latest, current) or semver.compare(a, b)

Plain string comparison says "1.10.0" > "1.9.0" is false (our run); semver compares the numbers.

semver.satisfies("1.9.0-beta.1", "^1.2.0") and expecting true
semver.satisfies(v, range, { includePrerelease: true }) when betas should count

Pre-releases are excluded from ranges by default; in our run the beta matched only with the flag.

Writing ^0.2.3 and expecting 0.3.0 to be accepted
Use >=0.2.3 <1.0.0 if you really want every 0.x update

For 0.x versions the caret rule only allows patch updates.

semver.clean("~1.0.0") or semver.valid("1.4")
semver.validRange("~1.0.0") for rules; semver.valid(semver.coerce("1.4")) for partial versions

clean() and valid() accept only full single versions; both returned null in our run.

Questions

What does a version number like 2.1.0 mean?

Under Semantic Versioning the first number goes up for breaking changes, the second for new features, the third for fixes.

Does it accept versions written as v1.2.3?

Yes. A leading v or = is stripped before the version is read.

Why does 1.9.0-beta.1 not match ^1.2.0?

Pre-release versions are left out of rules by default; pass { includePrerelease: true } to count them.

Can it clean up a rule like ~1.0.0?

No. clean() works only on single versions; for rules use validRange().