---
title: "What is the difference between ~ and ^ in package.json?"
description: "A caret allows minor and patch updates, a tilde allows only patch updates. See what each range accepts and when to pin an exact version."
url: "https://bugsee.com/answers/nodejs/tilde-vs-caret-in-package-json/"
---

# What is the difference between ~ and ^ in package.json?

`^1.4.2` accepts any `1.x.y` version at or above 1.4.2, while `~1.4.2` accepts only `1.4.y` patch updates.

- `^1.4.2` matches `>=1.4.2 and <2.0.0` (new features and fixes, no breaking changes).
- `~1.4.2` matches `>=1.4.2 and <1.5.0` (bug fixes only).
- `1.4.2` matches exactly that version.
- For `0.x` versions the caret is stricter: `^0.4.2` matches `>=0.4.2 and <0.5.0`.

`npm install` writes a caret by default. The lock file (`package-lock.json`) is what actually fixes the versions that get installed, so commit it and use `npm ci` in CI for reproducible builds.

## Related questions

- [What is the difference between npm and npx?](https://bugsee.com/answers/nodejs/difference-between-npm-and-npx/)
