A robust JavaScript implementation of the Semantic Versioning specification, used by npm for parsing and comparing version numbers.
semver is a JavaScript library that implements the Semantic Versioning (SemVer) 2.0.0 specification for parsing, comparing, and manipulating version numbers. It solves the problem of consistently interpreting version strings and ranges in software projects, enabling reliable dependency resolution and release automation. The library is the official version parser used by npm.
Node.js developers and tooling authors who need to programmatically handle version numbers, validate dependency ranges, or automate version bumping in their projects. It's also useful for CLI tool developers requiring semantic version parsing.
Developers choose semver because it's the battle-tested, specification-compliant library trusted by npm itself, offering a comprehensive API with modular imports for performance-sensitive applications. Its strict defaults ensure correctness, while loose modes provide flexibility for legacy version formats.
The semver parser for node (the one npm uses)
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Implements the complete SemVer 2.0.0 specification with support for versions, ranges, prerelease tags, and build metadata, ensuring correctness in dependency management and automation.
Offers dozens of functions like valid, satisfies, gt, lt, coerce, and intersects, covering all aspects of version parsing, comparison, and manipulation as detailed in the README.
Allows importing only specific functions or classes (e.g., semver/functions/compare) to enable tree-shaking and reduce bundle size in modern JavaScript applications.
Provides a command-line interface for sorting versions, checking ranges, and incrementing versions directly from the terminal, useful for automation scripts and DevOps workflows.
With over 30 functions and complex range syntax (e.g., tilde, caret, hyphen), developers new to SemVer or needing only basic operations may find the API overwhelming and hard to navigate.
While loose mode exists, coercion functions have constraints like truncating versions after 256 characters and ignoring components over 16 characters, which may not handle all edge cases in legacy systems.
Designed for Node.js environments, and although it can be bundled for browsers, it's not explicitly optimized for frontend use, potentially adding unnecessary weight for simple web apps.