A small, focused TypeScript library that validates standard 5-field cron expressions and converts supported patterns into human-readable English.
npm install cronwise- Validates standard 5-field cron expressions (minute, hour, day-of-month, month, day-of-week).
- Provides human-readable descriptions of supported cron expressions.
- Zero dependencies. Lightweight and fast.
- Written in TypeScript, with great TS support.
- Fully tested.
cronwise currently supports standard 5-field cron expressions with the following field syntax:
*(every value)- Exact numerical values (e.g.,
0,15) - Step values (e.g.,
*/15)
The following syntax is intentionally not supported in v1:
- Ranges (e.g.,
1-5) - Lists (e.g.,
1,2,3) - Named months (e.g.,
JAN) - Named weekdays (e.g.,
MON) - 6-field or 7-field cron syntax (seconds or years)
- Timezone handling
import { validateCron } from 'cronwise';
const result = validateCron('0 9 * * 1');
console.log(result.valid); // true
console.log(result.errors); // []
const invalid = validateCron('60 * * * *');
console.log(invalid.valid); // false
console.log(invalid.errors); // ["Minute must be between 0 and 59, or '*'"]import { explainCron } from 'cronwise';
console.log(explainCron('*/15 * * * *'));
// "Every 15 minutes"
console.log(explainCron('0 9 * * *'));
// "Every day at 09:00"
console.log(explainCron('0 9 * * 1'));
// "At 09:00 on Monday"If the cron expression is valid but not supported by the explainer yet, it returns:
Valid cron expression, but no human-readable explanation is available yet.
import { parseCron } from 'cronwise';
const result = parseCron('0 9 * * 1');
console.log(result.valid); // true
console.log(result.explanation); // "At 09:00 on Monday"Validates a cron expression and returns a CronValidationResult object.
Returns a human-readable string explaining the cron expression. Returns null if invalid 5 fields.
Parses and validates a cron expression, and returns the result with an explanation.
MIT