Skip to main content
current (v1.x.x)

Introduction

⏱️ @catbee/cron-parser – Cron expression parser for Node.js and TypeScript

A lightweight, timezone-aware cron expression parser with full support for seconds, DST transitions, iterators, randomized scheduling, and crontab file parsing. Built for production systems with clean TypeScript types and zero-config ESM/CJS support.

Build StatusCoverageNode VersionNPM VersionNPM DownloadsTypeScript TypesLicense

📦 Installation

npm install @catbee/cron-parser

Cron Format

*    *    *    *    *    *
┬ ┬ ┬ ┬ ┬ ┬
│ │ │ │ │ │
│ │ │ │ │ └─ day of week (0-7, 1L-7L) (0 or 7 is Sun)
│ │ │ │ └────── month (1-12, JAN-DEC)
│ │ │ └─────────── day of month (1-31, L)
│ │ └──────────────── hour (0-23)
│ └───────────────────── minute (0-59)
└────────────────────────── second (0-59, optional)

Special Characters

CharacterDescriptionExample
*Any value* * * * * (every minute)
?Any value (alias for *)? * * * * (every minute)
,Value list separator1,2,3 * * * * (1st, 2nd, and 3rd minute)
-Range of values1-5 * * * * (every minute from 1 through 5)
/Step values*/5 * * * * (every 5th minute)
LLast day of month/week0 0 L * * (midnight on last day of month)
#Nth day of month0 0 * * 1#1 (first Monday of month)
HRandomized valueH * * * * (random minute every hour)

Predefined Expressions

ExpressionDescriptionEquivalent
@yearlyOnce a year at midnight of January 10 0 0 1 1 *
@monthlyOnce a month at midnight of first day0 0 0 1 * *
@weeklyOnce a week at midnight on Sunday0 0 0 * * 0
@dailyOnce a day at midnight0 0 0 * * *
@hourlyOnce an hour at the beginning of the hour0 0 * * * *
@minutelyOnce a minute0 * * * * *
@secondlyOnce a second* * * * * *
@weekdaysEvery weekday at midnight0 0 0 * * 1-5
@weekendsEvery weekend at midnight0 0 0 * * 0,6

Field Values

FieldValuesSpecial CharactersAliases
second0-59* ? , - / H
minute0-59* ? , - / H
hour0-23* ? , - / H
day of month1-31* ? , - / H L
month1-12* ? , - / HJAN-DEC
day of week0-7* ? , - / H L #SUN-SAT (0 or 7 is Sunday)

Options

OptionTypeDescription
currentDateDate | string | numberCurrent date. Defaults to current local time in UTC. If not provided but startDate is set, startDate is used instead.
endDateDate | string | numberEnd date of iteration range. Sets the iteration range end point
startDateDate | string | numberStart date of iteration range. Sets the iteration range start point
tzstringTimezone (e.g. Europe/London)
hashSeedstringSeed used for H randomized field values
strictbooleanEnable strict validation for expression format and day-of-month/day-of-week rules

Supported string date formats:

  • ISO8601
  • HTTP and RFC2822
  • SQL