mrkeyoor.com_
Sun 20 Sept 08:53 UTC
npmWeb Backendupdated 20 Sept 2026

cron-parser review

cron-parser 5.10.0 converts cron text into a movable sequence of dates; it does not start timers or execute jobs. `CronExpressionParser.parse()` understands five fields, an optional seconds field, month and weekday names, presets, time zones, `L` and `#` selectors, and seeded Jenkins-style `H` values. Callers can move forward or backward, cap iteration with dates, inspect fields, or stringify an edited schedule. The 5.10.0 release fixes short expressions so missing values are padded from the leading field position. Our browser build measured 97.1 KB minified and 29.7 KB gzipped.

Verdict

cron-parser 5.10.0 installed in 0.7 seconds with 3 packages and 5 MB on disk in our sandbox, but its only output is calculated dates. Install it for validation, previews, and next-run arithmetic; choose a queue or scheduler when code execution and job supervision are the actual requirements.

We installed it

Lab card: what happened when we installed cron-parserScreenshot of cron-parser documentation
Install✓ · 0.7s3 packages on disk · 5 MB
ImportESM import works · require() works · CommonJS package
Browser29.7 KBgzipped (97.1 KB minified), bundled with esbuild
TypesTypeScript types bundled
Known vulns00 critical · 0 high · 0 moderate · 0 low (npm audit)

Answers from our run

Does cron-parser install cleanly?

Yes. In a fresh container with an empty cache, npm install cron-parser finished in 0.7s, leaving 3 packages and 5 MB on disk. npm audit reported no known vulnerabilities.

How much does cron-parser add to a browser bundle?

29.7 KB gzipped (97.1 KB minified) when the whole package is bundled for the browser with esbuild. Importing only part of it is usually smaller.

Does cron-parser work with both ESM and CommonJS?

Yes. Both import 'cron-parser' and require('cron-parser') worked in Node 22 in our run. The package is published as CommonJS.

Does cron-parser include TypeScript types?

Yes, type declarations ship inside the package, so no @types install is needed.

cron-parser or croner: which should you use?

croner: Choose it when the same package should parse cron text and invoke callbacks on schedule. cron-parser 5.10.0 installed in 0.7 seconds with 3 packages and 5 MB on disk in our sandbox, but its only output is calculated dates.

When should you not use cron-parser?

You expect the package to call a function, lock overlapping runs, retry failures, or persist job state; cron-parser only returns dates.

API stability3/5Version 5 replaced the v4 `parseExpression` entry with `CronExpressionParser.parse()` and changed the field-construction surface, so an upgrade across that boundary is a code migration. The 5.x API consistently exposes forward and backward cursor movement, ranges, time zones, field access, and stringify operations. Release 5.10.0 changes parsing of incomplete expressions without introducing another entry point, but that input correction can still alter previously accepted schedules.
Docs4/5The README lists all 6 field positions, aliases, presets, special characters, date options, strict-mode checks, hash syntax, time-zone use, and crontab file parsing with TypeScript examples. It also explains clamping and the exception raised after a date bound is exhausted. Generated API pages supply signatures, though readers get more behavioral detail from the README and must understand which extensions their destination cron service accepts.
Maintenance5/5GitHub shows an unarchived repository with 1,491 stars, 11 open issues and pull requests, and a push on August 18, 2026. Version 5.10.0 was published four days earlier on August 14 to correct short-expression padding. Recent releases also addressed strict hash validation and scheduling edge cases. The small combined queue and current branch activity give users concrete evidence that parser defects are still being investigated and shipped.
Ecosystem5/5npm counted 19,463,522 downloads from August 19 through August 25, 2026. Version 5.10.0 includes declarations, loaded through CommonJS require and ESM import in our Node 22 sandbox, and covers extensions commonly exposed by schedule editors. Luxon is its single runtime dependency. That dependency helps with zones and DST, but it also contributed to the 29.7 KB gzipped full browser result we measured.

Use it if

  • A scheduler stores its own next-run timestamp and needs repeatable calculations after each completed job.
  • A configuration screen must reject bad cron text and show the next several dates before saving it.
  • Schedules use named IANA zones and their dates must remain correct across daylight-saving transitions.
  • Your accepted dialect includes seconds, last days, nth weekdays, presets, or deterministic `H` offsets.
Skip it if

Setup reality

Our install of cron-parser 5.10.0 finished in 0.7 seconds in a clean Node 22 container. It left 3 packages and 5 MB on disk. The package has 1 direct dependency, no peer dependencies, and 268 KB unpacked, with bundled TypeScript declarations and a Node 18 minimum. npm audit reported 0 known vulnerabilities. The CommonJS package has no exports map, yet both require() and ESM import worked. Our complete browser import was 97.1 KB minified and 29.7 KB gzipped.

There are no credentials or configuration files. Time is the configuration that matters. Supply tz for every user-owned schedule and pass an explicit ISO currentDate in repeatable tests; otherwise results can follow the deployment host. A six-field expression starts with seconds, while the common five-field form starts with minutes. Version 5.10.0 changed how a short expression receives missing leading fields, so applications that intentionally accepted incomplete input should retest it.

A parsed expression owns a cursor. next(), prev(), take(), and iteration all move that cursor, and later calls continue from the new position. reset() returns it to the original current date. startDate and endDate define a permitted window; the parser clamps an initial current date into the window, but moving beyond an end throws. Use hasNext() or catch the documented range error in a worker that may exhaust its schedule.

Default mode accepts ambiguous combinations and even gives an empty expression a schedule. Strict mode rejects empty text, demands 6 fields, disallows simultaneous day restrictions, and checks whether hashed ranges and steps are usable. Give H a stable hashSeed when offsets must survive restarts. cron-parser calculates occurrences only, so concurrency control, retries, clock polling, persistence, and missed-run policy still belong to your queue or scheduler.

Patterns

Get the next matching date get-next-occurrence

import { CronExpressionParser } from 'cron-parser';

const schedule = CronExpressionParser.parse('0 9 * * 1-5');
const nextDate = schedule.next().toDate();

In version 5, `next()` returns a `CronDate` rather than a native Date. Call `toDate()` before handing the result to an API that checks `instanceof Date`.

Preview five future dates preview-occurrences

const schedule = CronExpressionParser.parse('*/15 * * * *');
const dates = schedule.take(5).map((item) => item.toISOString());

`take(5)` advances the same internal cursor used by `next()`. Run `reset()` before generating another preview from the expression's original current date.

Evaluate morning time in an IANA zone evaluate-timezone

const schedule = CronExpressionParser.parse('0 8 * * *', {
  currentDate: '2026-10-24T00:00:00Z',
  tz: 'Europe/London',
});

console.log(schedule.next().toISOString());

The `tz` option controls wall-clock evaluation through DST changes. Without it, a deployment in a different zone can produce a different 8:00 occurrence.

Validate a six-field form value validate-strict-input

function validateCron(value: string) {
  try {
    CronExpressionParser.parse(value, { strict: true });
    return null;
  } catch (error) {
    return error instanceof Error ? error.message : 'Invalid expression';
  }
}

Strict mode in 5.10.0 expects 6 fields with seconds first. A normal five-field crontab value fails this check even when a system cron daemon would accept it.

Stop iteration at an end date bound-date-range

const schedule = CronExpressionParser.parse('0 0 * * *', {
  startDate: '2026-09-01T00:00:00Z',
  endDate: '2026-09-08T00:00:00Z',
});

while (schedule.hasNext()) console.log(schedule.next().toISOString());

The initial cursor is clamped into the requested range. Once no match remains before `endDate`, an unguarded `next()` throws an out-of-range error.

Match at 30-second intervals include-seconds

const schedule = CronExpressionParser.parse('*/30 * * * * *');
console.log(schedule.take(4).map((item) => item.toISOString()));

cron-parser puts seconds in field 1 of the six-slot form. Basic POSIX crontab accepts only 5 slots, so do not pass this expression to a system crontab unchanged.

Match the final day of each month select-month-end

const monthEnd = CronExpressionParser.parse('0 0 L * *');
console.log(monthEnd.next().toISOString());

`L` is a cron extension rather than baseline POSIX syntax. Confirm that any downstream service storing the text implements the same last-day rule.

Match the first Monday of a month select-nth-weekday

const firstMonday = CronExpressionParser.parse('0 0 * * 1#1');
console.log(firstMonday.take(3).map((item) => item.toISOString()));

The `#` selector belongs to the weekday slot. Many system cron implementations reject it even though cron-parser 5.10.0 accepts and calculates it.

Assign a repeatable hashed offset seed-hash-value

const schedule = CronExpressionParser.parse('H/10 * * * *', {
  hashSeed: 'account-rollup',
});

console.log(schedule.stringify());

Use the same `hashSeed` for the same job on every parse. Without a seed, the chosen `H` value is not a stable deployment-time assignment.

Move backward to the previous match find-previous-occurrence

const schedule = CronExpressionParser.parse('0 6 * * 1', {
  currentDate: '2026-08-24T12:00:00Z',
});

console.log(schedule.prev().toISOString());

`prev()` mutates the cursor just like `next()`. Calling `next()` afterward moves forward from that previous match, not from the original noon current date.

Change parsed hour and minute fields modify-fields

import { CronExpressionParser, CronFieldCollection } from 'cron-parser';

const parsed = CronExpressionParser.parse('0 7 * * 1-5');
const fields = CronFieldCollection.from(parsed.fields, {
  hour: [8],
  minute: [30],
});
console.log(fields.stringify());

`CronFieldCollection.from()` retains fields omitted from its override. The returned collection is separate from the parsed expression and can be stringified as `30 8 * * 1-5`.

Parse schedules and variables from a crontab file read-crontab-file

import { CronFileParser } from 'cron-parser';

const result = await CronFileParser.parseFile('/etc/crontab');
if (Object.keys(result.errors).length) console.error(result.errors);
console.log(result.variables, result.expressions);

File parsing returns invalid-line errors beside valid variables and expressions. Inspect `errors` explicitly because one bad line does not discard the successfully parsed entries.

Alternatives

PackageRegistryPick it when
cronernpmChoose it when the same package should parse cron text and invoke callbacks on schedule.
cron-schedulenpmChoose it for parsing plus timer-based task execution with a different dependency profile.
laternpmChoose it when recurrence rules extend beyond cron into text schedules and custom periods.

More web backend guides

urllib3 · requests · ws · anyio · httpx · undici · the whole shelf →

How this guide is made: grounded in the library's documentation, release notes, changelog, and issue history, on a fixed rubric — not a hands-on install of every release. The 50 most-downloaded entries are additionally install-verified in clean containers. Corrections: contact the desk.