npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

posix-cron-parser

v1.0.0

Published

Zero-dependency, high-precision POSIX-compliant 5-field cron expression parser, English humanizer, and execution scheduler.

Readme

posix-cron-parser

npm version License: MIT Interactive Playground

A high-performance, zero-dependency, strict POSIX IEEE 1003.1 compliant 5-field cron expression parser, natural English translator, and execution date scheduler for TypeScript and JavaScript.

Interactive Visual Workbench: Test, debug, and visually edit any cron schedule with real-time execution graphs on the FastTools Visual Crontab Generator.


Features

  • Strict POSIX 5-Field Standard: Validates minute, hour, day of month, month, and day of week.
  • Zero External Dependencies: Pure TypeScript with zero runtime overhead and instant execution (<0.1ms).
  • Natural Language Translator: Translates complex expressions like */15 9-17 * * 1-5 into plain English descriptions ("Every 15 minutes, between 09:00 and 17:59, Monday through Friday").
  • Next Execution Calculator: Accurately computes future run timestamps while handling leap years, 28/29/30/31-day month boundaries, and POSIX union rules.
  • POSIX Day Union Rule: Correctly applies the standard POSIX union logic: when both day-of-month and day-of-week are specified, the job executes when either condition matches.
  • Special Aliases Support: Native parsing for @yearly, @annually, @monthly, @weekly, @daily, @midnight, and @hourly.
  • Dual Module Support: Full native ESM and CommonJS exports with complete TypeScript definitions.

Installation

npm install posix-cron-parser
# or
yarn add posix-cron-parser
# or
pnpm add posix-cron-parser

Quick Start

import { parseCron, describeCron, getNextRuns, isValidCron } from 'posix-cron-parser';

// 1. Quick Validation
console.log(isValidCron('*/5 * * * *')); // true
console.log(isValidCron('60 * * * *'));  // false (minute out of range)

// 2. Parse 5-Field Expression
const parsed = parseCron('0 9 * * 1-5');
console.log(parsed.isValid); // true
console.log(parsed.hour.values); // [9]
console.log(parsed.dayOfWeek.values); // [1, 2, 3, 4, 5]

// 3. Human-Readable English Description
const description = describeCron(parsed);
console.log(description);
// "At 09:00, Monday through Friday"

// 4. Calculate Next Executions
const nextRuns = getNextRuns(parsed, new Date(), 5);
nextRuns.forEach((date, i) => {
  console.log(`Run ${i + 1}: ${date.toISOString()}`);
});

Interactive Visual Tool

Need to design a schedule visually or share an interactive link with your team? Use our free, client-side web utility:

👉 FastTools Crontab Generator


API Reference

parseCron(expression: string): ParsedCron

Parses a 5-field cron string or alias. Returns the parsed fields, expanded matching integer sets, and validation status.

describeCron(parsed: ParsedCron): string

Generates an English description of the execution frequency and schedule.

getNextRuns(parsed: ParsedCron, from: Date, count: number): Date[]

Computes the next count execution instances chronologically from a starting Date.

isValidCron(expression: string): boolean

Fast boolean syntax and range checker.


Specification Reference

The parser strictly conforms to the POSIX crontab specification:

┌───────────── minute (0 - 59)
│ ┌───────────── hour (0 - 23)
│ │ ┌───────────── day of month (1 - 31)
│ │ │ ┌───────────── month (1 - 12 or JAN - DEC)
│ │ │ │ ┌───────────── day of week (0 - 7 or SUN - SAT, 0 & 7 = Sunday)
│ │ │ │ │
* * * * *

License

MIT © Alfaz Mahmud Rizve • Part of the FastTools Network