Cron Expression Explainer: how it works and how to build one
Read a cron schedule in plain English and see the next runs. This guide explains what happens behind the button and shows the code, so you can build your own.
What it does
Paste a 5-field cron expression like */15 9-17 * * 1-5 to see what it means in words and the next 10 times it will run in your time zone. Presets cover the common schedules.
When to use it
- Server crontabs
- GitHub Actions schedules
- Cloud Scheduler and Kubernetes CronJobs
How to use it
- Type or pick a cron expression.
- Read the description and next run times.
- Copy the expression into your crontab or CI file.
Try it free in your browser, nothing is uploaded: https://eskillsfy.com/tools/cron-expression
How it works
A cron expression has five fields: minute, hour, day of month, month and day of week. Each field can be *, a number, a list (1,15), a range (1-5) or a step (*/15). The parser turns each field into a set of allowed values.
To find the next runs, it walks forward minute by minute (skipping whole days or hours that can’t match) and keeps times where every field matches. One quirk: if both day fields are restricted, cron runs when either matches.
Build it yourself
Here is the core of the tool. It has no dependencies unless noted, so you can paste it into any TypeScript or JavaScript project.
cron.ts (ts)
const RANGES = [[0, 59], [0, 23], [1, 31], [1, 12], [0, 6]];
export function parseField(field: string, i: number) {
const [lo, hi] = RANGES[i], out = new Set<number>();
for (const part of field.split(",")) {
const [range, step = "1"] = part.split("/");
const [a, b] = range === "*" ? [lo, hi] : range.includes("-") ? range.split("-").map(Number) : [+range, step !== "1" ? hi : +range];
for (let v = a; v <= b; v += +step) out.add(v);
}
return out;
}
export function nextRuns(expr: string, count = 5) {
const sets = expr.trim().split(/\s+/).map(parseField);
const d = new Date(); d.setSeconds(0, 0);
const runs: Date[] = [];
while (runs.length < count) {
d.setMinutes(d.getMinutes() + 1);
if (sets[0].has(d.getMinutes()) && sets[1].has(d.getHours()) && sets[2].has(d.getDate()) && sets[3].has(d.getMonth() + 1) && sets[4].has(d.getDay())) runs.push(new Date(d));
}
return runs;
}
Make it production-ready
- Skip ahead by hour or day when those fields don’t match (much faster).
- Handle names like MON and JAN and the 7 = Sunday alias.
Questions
Are seconds supported?
Standard cron has 5 fields (minute, hour, day, month, weekday). Some tools add a seconds field; remove it before pasting here.
Which time zone?
Next runs are shown in your browser’s time zone. Servers often run cron in UTC.
Free, runs in your browser, nothing is uploaded.