# SemVer

> The SemVer (Semantic Versioning) is a versioning scheme in the MAJOR.MINOR.PATCH format.

## What is semantic versioning and what do ^ and ~ mean?

The versioning scheme where a version looks like '2.4.1'. The major number grows on breaking changes, the minor on new backward-compatible features and the patch on bug fixes. Used by npm to resolve ranges like '^2.4.1'.

- Topic: Practices
- Type: concept

## Example

Wrong:

```json
{
  "name": "my-lib",
  "version": "1.4"
}
```

Right:

```json
{
  "name": "my-lib",
  "version": "1.4.0"
}
```

SemVer needs all three numbers, so npm rejects '1.4' as an invalid version and accepts '1.4.0'.

## Common mistakes

- Releasing a breaking change as a minor update, which breaks every `^` range user.

## Key points

- A breaking change bumps MAJOR, a new feature bumps MINOR, a fix bumps PATCH.
- Caret `^` ranges allow minor and patch updates, tilde `~` allows only patch updates.
- Caret ranges on '0.x' versions allow only patch updates, since anything can break before the first major.

## Interview questions

### What does a pre-release version like 1.0.0-beta.1 mean?

A hyphen suffix marks a pre-release. It sorts before the normal release and ranges like `^1.0.0` do not match it by default.

### When should a package reach 1.0.0?

When its public API is stable and used in production. Before that, any minor bump may contain breaking changes.

### Does SemVer apply to apps or only libraries?

It is designed for anything with a public API, mostly libraries. Apps often use simpler date or build numbers.

## Related cards

- [`npm version <x.x.x>`](https://wonderium.dev/processes/npm-version.md)
- [package.json](https://wonderium.dev/processes/package-json.md)
- [Lock file](https://wonderium.dev/processes/lock-file.md)
- [Conventional Commits](https://wonderium.dev/processes/conventional-commits.md)
- [Release](https://wonderium.dev/processes/release.md)

---

- Level: [Processes](https://wonderium.dev/processes.md)
- HTML version: https://wonderium.dev/processes/semver
- Last updated: 2026-11-25
