Skip to main content

Moment.js

Deprecated

Do not use for new projects. Use Luxon as the default replacement. date-fns is an alternative when only a few utility functions are needed. The native Temporal API is an option for projects targeting modern browsers only (~69% global coverage as of May 2026); use @js-temporal/polyfill everywhere else.

What is it

Moment.js is a JavaScript date/time library for parsing, validating, manipulating, and formatting dates. It was the standard date library for nearly a decade (2011–2020).

Why it's deprecated

  • Self-declared legacy project — the Moment team says "We now generally consider Moment to be a legacy project in maintenance mode. It is not dead, but it is indeed done."
  • Massive bundle size — doesn't support tree-shaking; adds ~70 KB min+gzip (with locales potentially 230 KB+).
  • Mutable API — Moment objects are mutable, a common source of bugs.
  • Native Temporal API is landing — full support in Chrome 144+, Edge 144+, Firefox 139+ (~69% global coverage as of May 2026).
  • Superior alternatives existLuxon (immutable, built-in time zones and i18n, 21 kB), date-fns (modular, tree-shakable), Day.js.

Luxon — the default replacement. Immutable API, built-in time zone and i18n support, and a clean migration path from Moment. date-fns is a lighter alternative when only a few utility functions are needed. The native Temporal API is available in Chrome 144+, Edge 144+, and Firefox 139+ but still lacks Safari support; it is appropriate only for B2B apps with controlled browsers.

Migration path

  1. Replace moment() calls with Luxon's DateTime — see the Luxon migration guide for Moment users
  2. Replace moment.duration() with Duration and moment.range patterns with Interval
  3. Replace moment-timezone usage — Luxon handles IANA time zones natively
  4. Alternative: date-fns — replace moment() calls with date-fns functions (format, addDays, differenceInDays, etc.) if only simple utilities are needed
  5. Alternative: Temporal — use Temporal.PlainDate, Temporal.ZonedDateTime, etc. Use @js-temporal/polyfill for environments without native support
  6. Audit all moment() usage — codemods exist (e.g., moment-to-dayjs-codemod)
  7. Remove moment and moment-timezone from dependencies

Resources