Gathering detailed insights and metrics for cronstrue
Gathering detailed insights and metrics for cronstrue
Gathering detailed insights and metrics for cronstrue
Gathering detailed insights and metrics for cronstrue
JavaScript library that translates Cron expressions into human readable descriptions
npm install cronstrue
Typescript
Module System
Node Version
NPM Version
TypeScript (96.6%)
JavaScript (3.4%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
1,450 Stars
1,025 Commits
180 Forks
7 Watchers
3 Branches
63 Contributors
Updated on Jul 13, 2025
Latest Version
3.0.0
Package Id
cronstrue@3.0.0
Unpacked Size
1.09 MB
Size
137.81 kB
File Count
133
NPM Version
8.19.4
Node Version
16.20.2
Published on
Jul 01, 2025
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
Would you take a quick second and ⭐️ my repo?
cRonstrue is a JavaScript library that parses a cron expression and outputs a human readable description of the cron schedule. For example, given the expression "*/5 * * * *" it will output "Every 5 minutes".
This library was ported from the original C# implementation called cron-expression-descriptor and is also available in a few other languages.
A demo is available here.
cRonstrue is exported as an UMD module so it will work in an AMD, CommonJS or browser global context.
First, install the module:
npm install cronstrue
Then, depending upon your usage context, add a reference to it:
1const cronstrue = require('cronstrue');
1import cronstrue from 'cronstrue';
The cronstrue.min.js
file from the /dist
folder in the npm package should be served to the browser. There are no dependencies so you can simply include the library in a <script>
tag.
1<script src="cronstrue.min.js" type="text/javascript"></script> 2<script> 3 var cronstrue = window.cronstrue; 4</script>
A simple way to load the library in a browser is by using the unpkg CDN, which is a "fast, global content delivery network for everything on npm". To use it, include a script tag like this in your file:
1<script src="https://unpkg.com/cronstrue@latest/dist/cronstrue.min.js" async></script>
Using the "latest" tag will result in a 302 redirect to the latest version tag so it is recommended to use a specific version tag such as https://unpkg.com/cronstrue@1.48.0/dist/cronstrue.min.js to avoid this redirect.
1cronstrue.toString("* * * * *"); 2> "Every minute" 3 4cronstrue.toString("0 23 ? * MON-FRI"); 5> "At 11:00 PM, Monday through Friday" 6 7cronstrue.toString("0 23 * * *", { verbose: true }); 8> "At 11:00 PM, every day" 9 10cronstrue.toString("23 12 * * SUN#2"); 11> "At 12:23 PM, on the second Sunday of the month" 12 13cronstrue.toString("23 14 * * SUN#2", { use24HourTimeFormat: true }); 14> "At 14:23, on the second Sunday of the month" 15 16cronstrue.toString("* * * ? * 2-6/2", { dayOfWeekStartIndexZero: false }); 17> "Every second, every 2 days of the week, Monday through Friday" 18 19cronstrue.toString("* * * 6-8 *", { monthStartIndexZero: true }); 20> "Every minute, July through September" 21 22cronstrue.toString("@monthly"); 23> "At 12:00 AM, on day 1 of the month"
For more usage examples, including a demonstration of how cRonstrue can handle some very complex cron expressions, you can reference the unit tests.
1$ npm install -g cronstrue 2 3$ cronstrue 1 2 3 4 5 4At 02:01 AM, on day 3 of the month, and on Friday, only in April 5 6$ cronstrue 1 2 3 7Error: too few arguments (3): 1 2 3 8Usage (5 args): cronstrue minute hour day-of-month month day-of-week 9or 10Usage (6 args): cronstrue second minute hour day-of-month month day-of-week 11or 12Usage (7 args): cronstrue second minute hour day-of-month month day-of-week year
An options object can be passed as the second parameter to cronstrue.toString
. The following options are available:
1
as Sunday or Monday. (Default: true)0
or 1
. (Default: false)To use the i18n support cRonstrue provides, you can either import all the supported locales at once (using cronstrue/i18n
) or import individual locales (using cronstrue/locales/[locale]
). Then, when calling toString
you pass in the name of the locale you want to use. For example, for the es (Spanish) locale, you would use: cronstrue.toString("* * * * *", { locale: "es" })
.
You can import all locales at once with cronstrue/i18n
. This approach has the advantage of only having to load one module and having access to all supported locales. The tradeoff with this approach is a larger module (~130k, minified) that will take longer to load, particularly when sending down to a browser.
1// Node / CommonJS 2const cronstrue = require('cronstrue/i18n'); 3 4// ESM / webpack / TypeScript 5import cronstrue from 'cronstrue/i18n'; 6 7// Browser 8<script src="https://unpkg.com/cronstrue@latest/cronstrue-i18n.min.js" async></script> 9 10cronstrue.toString("*/5 * * * *", { locale: "fr" }); // => Toutes les 5 minutes 11cronstrue.toString("*/5 * * * *", { locale: "es" }); // => Cada 5 minutos
You can also load the main cronstrue module and then load individual locale modules you want to have access to. This works well when you have one or more locales you know you need access to and want to minimize load time, particularly when sending down to a browser. The main cronstrue module is about 42k (minified) and each locale is about 4k (minified) in size.
1// Node / CommonJS 2const cronstrue = require('cronstrue'); 3require('cronstrue/locales/fr'); 4require('cronstrue/locales/es'); 5 6// ESM / webpack / TypeScript 7import cronstrue from 'cronstrue'; 8import 'cronstrue/locales/fr'; 9import 'cronstrue/locales/es'; 10 11// Browser 12<script src="https://unpkg.com/cronstrue@latest/dist/cronstrue.min.js" async></script> 13<script src="https://unpkg.com/cronstrue@latest/locales/fr.min.js" async></script> 14<script src="https://unpkg.com/cronstrue@latest/locales/es.min.js" async></script> 15 16cronstrue.toString("*/5 * * * *", { locale: "fr" }); // => Toutes les 5 minutes 17cronstrue.toString("*/5 * * * *", { locale: "es" }); // => Cada 5 minutos
The cron expression I am passing in is not valid and this library is giving strange output. What should I do?
This library does not do full validation of cron expressions and assumes the expression passed in is valid. If you need to validate an expression consider using a library like cron-parser. Example validation with cron-parser:
const cronParser = require("cron-parser");
const cronstrue = require("cronstrue");
const expression = "* * * * * *";
// Validate expression first
let isCronValid = true;
try { cronParser.parseExpression(expression) } catch(e) { isCronValid = false; }
// If valid, then pass into cRonstrue
if (isCronValid) {
console.log(cronstrue.toString("* * * * *"));
}
Can cRonstrue output the next occurrence of the cron expression?
No, cRonstrue does not support this. This library simply describes a cron expression that is passed in.
The following locales can be passed in for the locale
option. Thank you to the author (shown below) of each translation!
Thank you to the following sponsors of this project!
cRonstrue is freely distributable under the terms of the MIT license.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
8 commit(s) and 7 issue activity found in the last 90 days -- score normalized to 10
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
5 existing vulnerabilities detected
Details
Reason
Found 12/29 approved changesets -- score normalized to 4
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
Project has not signed or included provenance with any releases.
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More