Comparing the JS datetime libraries

Comparing date-fns, dayjs, luxon, moment

Back

I've been working with various date libraries written in Javascript / Typescript, some of them are great, some are good enough. You probably used some of those already. Let's make a nerdy comparison.

Criteria

I'm going with following bullets:

  • NPM trending
  • Update frequency
  • API and usage
  • Bundle size

NPM trending

dama

So we can see: date-fns > dayjs = moment > luxon

Link to npmtrends: Here

Update frequency

No matter how good the library is, if it's not actively maintained, it won't be good in the long run, which includes bug fixes, compatibility patches and security patches. The libraries are updated frequently. So it's a good sign (except for momentjs).

API and usage

date-fns is built on top of native Date, which is why it's so lightweight. Their usages are similar, and are quite easy to approach.

  • dayjs
import dayjs from "dayjs";

const date = dayjs().format("YYYY-MM-DD");
console.log(date);
  • date-fns
import { format } from "date-fns";

const date = format(new Date(), "YYYY-MM-DD");
  • luxon
import { DateTime } from "luxon";

const date = DateTime.now().toLocaleString(DateTime.DATE_FULL);
  • moment - same with dayjs
import moment from "moment";

const date = moment().format("YYYY-MM-DD");
console.log(date);

Bundle size

Now let's take a look at the library sizes. We have original size (quoted from npmjs.com), and bundled size (quoted from bundlephobia).

LibOriginal sizeBundled size (minified)Bundled size (minified + gzipped)
dayjs672 KB6.9 KB3 KB
date-fns22 MB77.2 KB17. KB
luxon4.59 MB81.6 KB24.1 KB
moment4.35 MB294.9 KB73.1 KB

dayjs is the smallest, thanks to modular design. Timezone and extended locale are available through plugin system. It's also easy for tree-shaking.

Conclusion

I'm good with moment and dayjs, so I'm continuing to use them (mostly dayjs). date-fns is also being used in one of my pet project as well. They are all mature libraries, so pick what you are familiar at, considering the requirements as well.

LibTrendingUpdate frequencyAPI and usageBundle size
dayjs
date-fns
luxon
moment

Written by

Kuon

At

Thu Oct 30 2025

Tags

#programming