Difference between Caret (^) and Tilde (~) in package.json. Did you know?
• JavaScript, Node.js, NPM, Package Management, Semantic Versioning
• 1 min read
The difference between a Caret and Tilde in package.json. Did you know it is simpler than it looks? and at the same time a nuance that you can easily forget?
Semantic Versioning
When working with package.json and defining a strategy for how packages are updated, I always tend to forget the meaning of the symbols, so for our own sake, I’m documenting this here :)
Let’s look at the following:
| |
| |
Both versions use Semantic Versioning, represented by the definition of MAJOR.MINOR.PATCH.
| |
So according to this table:
| Symbol | Dependency | Versions | Changes |
|---|---|---|---|
| caret(^) | ^2.3.1 | 2.X.X | backwards compatibility, minor increment |
| tilde(~) | ~2.3.1 | 2.3.X | bug fix |
Caret(^) allows for incremental changes of MINOR and PATCH:

Tilde(~) allows for incremental changes of PATCH only:

Feel free to save this reference for your own records.

Join the conversation! Share your thoughts and connect with other readers.