Best Moment.JS Alternatives
Comparing size, performance, Typescript support and more
Moment.js is indeed done
It has been a popular library for parsing, validating, manipulating, and formatting dates for a decade. However, Moment.js has too many drawbacks compared to modern date and time libraries. Its API is not immutable, it is large and it doesn’t support tree shaking. Even the Moment team discourages to use their library in new projects.
“We now generally consider Moment to be a legacy project in maintenance mode. It is not dead, but it is indeed done.” — The Moment team
Modern alternatives
There are multiple solid date and time libraries for JavaScript you can use instead. We’ll look into Luxon, Day.js, date-fns and js-joda.
The following comparison includes attributes that should help you choose the right one for your project.
GitHub stars

NPM packages using the libraries

Public GitHub repositories using the libraries

Immutability

TypeScript support

Performance
The following charts show one common operation from each type of date and time manipulation. Each operation in the chart was run 100 000 times.
Types of date and time manipulation
- Parsing — parseISO
- Formatting — YYYY-MM-DD
- Transformation — add 2 years
- Difference — diff in months between 2 instances
- Comparing — is one instance before another instance in time?

From the chart above, you can see that there’s no library that is best for all the operations. Another significant result shows that even 100 000 runs take less than 3 seconds. If you don’t need to process some big data, you shouldn’t be worried about performance of the libraries.
Size
Each size measurement includes the library, its companion library for time zone support if there’s one and polyfills. The polyfills are required for libraries that use the Intl API for locales, time zones, or both.

Code examples
The entire source code: https://github.com/pixochi/moment-js-alternatives










