Skip to main content

The Difference Between Tilde and Caret in NPM package.json

The Difference Between Tilde and Caret in NPM package.json

The difference between tilde (~) and caret (^) used to specify acceptable versions in package.json was always a blur in my mind for a while. So this article is probably more for me than you.

Given the following version definition:

x.x.x = major.minor.patch

~ matches the patch version only, so ~1.2.0 will match versions 1.2.x but will ignore 1.3.x

^ matches the minor version and patch versions, so ^1.2.0 will match 1.x.x including 1.3.x but will ignore 2.x.x.