Semantic Versioning Cheat Sheet: SemVer Rules & Ranges
SemVer increment rules and dependency range operators in one reference.
When to bump MAJOR, MINOR, or PATCH - and how version ranges resolve.
Increment rules
| Bump | When |
|---|---|
| MAJOR (1.0.0) | Breaking / incompatible change |
| MINOR (0.1.0) | Backward-compatible feature |
| PATCH (0.0.1) | Backward-compatible bug fix |
| 0.x.y | Anything may break (initial dev) |
Pre-release & metadata
| Form | Means |
|---|---|
| 1.0.0-alpha.1 | Prerelease (lower precedence) |
| 1.0.0-rc.2 | Release candidate |
| 1.0.0+build.5 | Build metadata (ignored in precedence) |
npm range operators
| Range | Matches |
|---|---|
| ^1.2.3 | >=1.2.3 <2.0.0 (no major bump) |
| ~1.2.3 | >=1.2.3 <1.3.0 (patch only) |
| 1.x / 1.* | Any 1.y.z |
| >=1.2.0 <2.0.0 | Explicit range |
| 1.2.3 | Exact pin |
| * | Any version |
Key takeaways
- Breaking changes require a MAJOR bump - always.
- ^ allows minor+patch; ~ allows patch only.
- Prerelease tags sort below the same version without them.
Related guides
npm Scripts Cheat Sheet: Commands, Lifecycle & CI FlagsAn npm scripts cheat sheet - run, ci, install, lifecycle hooks, pre/post scripts, and the npm flags you use i…
Git CLI Cheat Sheet: Config, Remotes, Stash & TagsA Git CLI cheat sheet - config, remotes, stash, tags, cherry-pick, bisect, and the plumbing commands beyond t…
Git Branching Cheat Sheet: Branches, Merge & RebaseA Git branching cheat sheet - create, switch, merge, rebase, delete branches, plus fast-forward vs merge comm…