{"id":15409569,"url":"https://github.com/bradymholt/cronstrue","last_synced_at":"2025-05-08T22:25:04.042Z","repository":{"id":37664828,"uuid":"61157883","full_name":"bradymholt/cRonstrue","owner":"bradymholt","description":"JavaScript library that translates Cron expressions into human readable descriptions","archived":false,"fork":false,"pushed_at":"2025-05-08T20:24:44.000Z","size":2924,"stargazers_count":1401,"open_issues_count":4,"forks_count":177,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-05-08T20:55:41.635Z","etag":null,"topics":["cron","cron-expression","cron-libraries","quartz-scheduler"],"latest_commit_sha":null,"homepage":"http://bradymholt.github.io/cRonstrue/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bradymholt.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":["bradymholt"]}},"created_at":"2016-06-14T21:46:51.000Z","updated_at":"2025-05-08T20:24:47.000Z","dependencies_parsed_at":"2024-04-02T19:31:43.957Z","dependency_job_id":"2fbb962c-e40f-4c88-a6de-aa27b054b8fc","html_url":"https://github.com/bradymholt/cRonstrue","commit_stats":{"total_commits":834,"total_committers":65,"mean_commits":"12.830769230769231","dds":"0.36450839328537166","last_synced_commit":"f44efff5e83becb56426cc106a399e67cf11cb39"},"previous_names":["bradyholt/cronstrue"],"tags_count":224,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bradymholt%2FcRonstrue","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bradymholt%2FcRonstrue/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bradymholt%2FcRonstrue/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bradymholt%2FcRonstrue/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bradymholt","download_url":"https://codeload.github.com/bradymholt/cRonstrue/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253156412,"owners_count":21862910,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cron","cron-expression","cron-libraries","quartz-scheduler"],"created_at":"2024-10-01T16:40:38.008Z","updated_at":"2025-05-08T22:25:04.015Z","avatar_url":"https://github.com/bradymholt.png","language":"TypeScript","funding_links":["https://github.com/sponsors/bradymholt"],"categories":[],"sub_categories":[],"readme":"# cRonstrue ![Build Status](https://github.com/bradymholt/cRonstrue/workflows/Build/badge.svg) [![NPM Package](https://img.shields.io/npm/v/cronstrue.svg)](https://www.npmjs.com/package/cronstrue)\n\n\u003cimg align=\"left\" src=\"https://user-images.githubusercontent.com/759811/210273710-b13913e2-0a71-4d9d-94da-1fe538b8a73e.gif\"/\u003e\n\n\u003cbr/\u003e\n\n \u0026nbsp;**Would you take a quick second and ⭐️ my repo?**\n\n\u003cbr/\u003e\n\ncRonstrue 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\".\n\nThis library was ported from the original C# implementation called [cron-expression-descriptor](https://github.com/bradymholt/cron-expression-descriptor) and is also available in a [few other languages](https://github.com/bradymholt/cron-expression-descriptor#ports).\n\n## Features\n- Zero dependencies\n- Supports all cron expression special characters including * / , - ? L W, #\n- Supports 5, 6 (w/ seconds or year), or 7 (w/ seconds and year) part cron expressions\n- [Quartz Job Scheduler](http://www.quartz-scheduler.org/) cron expressions are supported\n- i18n support with 30+ languages\n\n## Demo\n\nA demo is available [here](http://bradymholt.github.io/cRonstrue/#cronstrue-demo).\n\n## Installation\ncRonstrue is exported as an [UMD](https://github.com/umdjs/umd) module so it will work in an [AMD](https://github.com/amdjs/amdjs-api/wiki/AMD), [CommonJS](http://wiki.commonjs.org/wiki/CommonJS) or browser global context.\n\nFirst, install the module:\n\n```\nnpm install cronstrue\n```\n\nThen, depending upon your usage context, add a reference to it:\n\n### Node / CommonJS\n\n```js\nconst cronstrue = require('cronstrue');\n```\n\n### ESM / webpack / TypeScript\n\n```js\nimport cronstrue from 'cronstrue';\n```\n\n### Browser\n 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 `\u003cscript\u003e` tag.\n\n```html\n\u003cscript src=\"cronstrue.min.js\" type=\"text/javascript\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n  var cronstrue = window.cronstrue;\n\u003c/script\u003e\n```\n\n#### CDN\n\nA simple way to load the library in a browser is by using the [unpkg](https://unpkg.com/) CDN, which is a\n\"fast, global content delivery network for everything on npm\".  To use it, include a script tag like this in your file:\n\n```html\n\u003cscript src=\"https://unpkg.com/cronstrue@latest/dist/cronstrue.min.js\" async\u003e\u003c/script\u003e\n```\n\nUsing 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.\n\n## Usage\n\n```js\ncronstrue.toString(\"* * * * *\");\n\u003e \"Every minute\"\n\ncronstrue.toString(\"0 23 ? * MON-FRI\");\n\u003e \"At 11:00 PM, Monday through Friday\"\n\ncronstrue.toString(\"0 23 * * *\", { verbose: true });\n\u003e \"At 11:00 PM, every day\"\n\ncronstrue.toString(\"23 12 * * SUN#2\");\n\u003e \"At 12:23 PM, on the second Sunday of the month\"\n\ncronstrue.toString(\"23 14 * * SUN#2\", { use24HourTimeFormat: true });\n\u003e \"At 14:23, on the second Sunday of the month\"\n\ncronstrue.toString(\"* * * ? * 2-6/2\", { dayOfWeekStartIndexZero: false });\n\u003e \"Every second, every 2 days of the week, Monday through Friday\"\n\ncronstrue.toString(\"* * * 6-8 *\", { monthStartIndexZero: true });\n\u003e \"Every minute, July through September\"\n\ncronstrue.toString(\"@monthly\");\n\u003e \"At 12:00 AM, on day 1 of the month\"\n\n```\n\nFor more usage examples, including a demonstration of how cRonstrue can handle some very complex cron expressions, you can [reference the unit tests](https://github.com/bradymholt/cRonstrue/blob/main/test/cronstrue.ts).\n\n### CLI Usage\n\n```sh\n$ npm install -g cronstrue\n\n$ cronstrue 1 2 3 4 5\nAt 02:01 AM, on day 3 of the month, and on Friday, only in April\n\n$ cronstrue 1 2 3\nError: too few arguments (3): 1 2 3\nUsage (5 args): cronstrue minute hour day-of-month month day-of-week\nor\nUsage (6 args): cronstrue second minute hour day-of-month month day-of-week\nor\nUsage (7 args): cronstrue second minute hour day-of-month month day-of-week year\n```\n\n## Options\n\nAn options object can be passed as the second parameter to `cronstrue.toString`.  The following options are available:\n\n- **throwExceptionOnParseError: boolean** - If exception occurs when trying to parse expression and generate description, whether to throw or catch and output the Exception message as the description. (Default: true)\n- **verbose: boolean** - Whether to use a verbose description (Default: false)\n- **dayOfWeekStartIndexZero: boolean** - Whether to interpret cron expression DOW `1` as Sunday or Monday. (Default: true)\n- **monthStartIndexZero: boolean** - Wether to interpret January as `0` or `1`. (Default: false)\n- **use24HourTimeFormat: boolean** - If true, descriptions will use a [24-hour clock](https://en.wikipedia.org/wiki/24-hour_clock) (Default: false but some translations will default to true)\n- **locale: string** - The locale to use (Default: \"en\")\n\n## i18n\n\nTo 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\" })`.\n\n### All Locales\n\nYou 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.\n\n```js\n// Node / CommonJS\nconst cronstrue = require('cronstrue/i18n');\n\n// ESM / webpack / TypeScript\nimport cronstrue from 'cronstrue/i18n';\n\n// Browser\n\u003cscript src=\"https://unpkg.com/cronstrue@latest/cronstrue-i18n.min.js\" async\u003e\u003c/script\u003e\n\ncronstrue.toString(\"*/5 * * * *\", { locale: \"fr\" }); // =\u003e Toutes les 5 minutes\ncronstrue.toString(\"*/5 * * * *\", { locale: \"es\" }); // =\u003e Cada 5 minutos\n```\n\n### Individual Locales\n\nYou 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.\n\n```js\n// Node / CommonJS\nconst cronstrue = require('cronstrue');\nrequire('cronstrue/locales/fr');\nrequire('cronstrue/locales/es');\n\n// ESM / webpack / TypeScript\nimport cronstrue from 'cronstrue';\nimport 'cronstrue/locales/fr';\nimport 'cronstrue/locales/es';\n\n// Browser\n\u003cscript src=\"https://unpkg.com/cronstrue@latest/dist/cronstrue.min.js\" async\u003e\u003c/script\u003e\n\u003cscript src=\"https://unpkg.com/cronstrue@latest/locales/fr.min.js\" async\u003e\u003c/script\u003e\n\u003cscript src=\"https://unpkg.com/cronstrue@latest/locales/es.min.js\" async\u003e\u003c/script\u003e\n\ncronstrue.toString(\"*/5 * * * *\", { locale: \"fr\" }); // =\u003e Toutes les 5 minutes\ncronstrue.toString(\"*/5 * * * *\", { locale: \"es\" }); // =\u003e Cada 5 minutos\n```\n\n## Frequently Asked Questions\n\n1. The cron expression I am passing in is not valid and this library is giving strange output.  What should I do?\n\n    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](https://www.npmjs.com/package/cron-parser).  Example validation with cron-parser:\n\n   ```\n   const cronParser = require(\"cron-parser\");\n   const cronstrue = require(\"cronstrue\");\n\n   const expression = \"* * * * * *\";\n\n   // Validate expression first\n   let isCronValid = true;\n   try { cronParser.parseExpression(expression) } catch(e) { isCronValid = false; }\n\n   // If valid, then pass into cRonstrue\n   if (isCronValid) {\n     console.log(cronstrue.toString(\"* * * * *\"));\n   }\n   ```\n\n2. Can cRonstrue output the next occurrence of the cron expression?\n\n    No, cRonstrue does not support this.  This library simply describes a cron expression that is passed in.\n\n### Supported Locales\n\nThe following locales can be passed in for the `locale` option.  Thank you to the author (shown below) of each translation!\n\n- en - English ([Brady Holt](https://github.com/bradymholt))\n- af - Afrikaans (Michael van Niekerk(https://github.com/mvniekerk))\n- ar - Arabic ([Mohamed Nehad Shalabi](https://github.com/mohamednehad450))\n- be - Belarusian ([Kirill Mikulich](https://github.com/KirillMikulich))\n- bg - Bulgarian ([kamenf](https://github.com/kamenf))\n- ca - Catalan ([Francisco Javier Barrena](https://github.com/fjbarrena))\n- cs - Czech ([hanbar](https://github.com/hanbar))\n- es - Spanish ([Ivan Santos](https://github.com/ivansg))\n- da - Danish ([Rasmus Melchior Jacobsen](https://github.com/rmja))\n- de - German ([Michael Schuler](https://github.com/mschuler))\n- fi - Finnish ([Mikael Rosenberg](https://github.com/MR77FI))\n- fr - French ([Arnaud TAMAILLON](https://github.com/Greybird))\n- fa - Farsi ([A. Bahrami](https://github.com/alirezakoo))\n- he - Hebrew ([Ilan Firsov](https://github.com/IlanF))\n- hu - Hungarian ([Orcsity Norbert](https://github.com/Northber), Szabó Dániel)\n- it - Italian ([rinaldihno](https://github.com/rinaldihno))\n- id - Indonesia ([Hasan Basri](https://github.com/hasanbasri1993))\n- ja - Japanese ([Alin Sarivan](https://github.com/asarivan))\n- ko - Korean ([Ion Mincu](https://github.com/ionmincu))\n- my - Malay (Malaysia) ([Ikhwan Abdullah](https://github.com/leychay))\n- nb - Norwegian ([Siarhei Khalipski](https://github.com/KhalipskiSiarhei))\n- nl - Dutch ([TotalMace](https://github.com/TotalMace))\n- pl - Polish ([foka](https://github.com/foka))\n- pt_BR - Portuguese (Brazil) ([Renato Lima](https://github.com/natenho))\n- pt_PT - Portuguese (Portugal) ([POFerro](https://github.com/POFerro))\n- ro - Romanian ([Illegitimis](https://github.com/illegitimis))\n- ru - Russian ([LbISS](https://github.com/LbISS))\n- sk - Slovakian ([hanbar](https://github.com/hanbar))\n- sl - Slovenian ([Jani Bevk](https://github.com/jenzy))\n- sw - Swahili ([Leylow Lujuo](https://github.com/leyluj))\n- sv - Swedish ([roobin](https://github.com/roobin))\n- th - Thai ([Teerapat Prommarak](https://github.com/xeusteerapat))\n- tr - Turkish ([Mustafa SADEDİL](https://github.com/sadedil))\n- uk - Ukrainian ([Taras](https://github.com/tbudurovych))\n- vi - Vietnamese ([Nguyen Tan Phap](https://github.com/rikkapro0128))\n- zh_CN - Chinese (Simplified) ([Star Peng](https://github.com/starpeng))\n- zh_TW - Chinese (Traditional) ([Ricky Chiang](https://github.com/metavige))\n\n## Sponsors\n\nThank you to the following sponsors of this project!\n\n\u003ca href=\"https://github.com/microsoft\"\u003e\u003cimg src=\"https://github.com/microsoft.png\" width=\"50px\" alt=\"robjtede\" style=\"max-width: 100%;\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/github\"\u003e\u003cimg src=\"https://github.com/github.png\" width=\"50px\" alt=\"robjtede\" style=\"max-width: 100%;\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/DevUtilsApp\"\u003e\u003cimg src=\"https://github.com/DevUtilsApp.png\" width=\"50px\" alt=\"robjtede\" style=\"max-width: 100%;\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/getsentry\"\u003e\u003cimg src=\"https://github.com/getsentry.png\" width=\"50px\" alt=\"robjtede\" style=\"max-width: 100%;\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/KevinWang15\"\u003e\u003cimg src=\"https://github.com/KevinWang15.png\" width=\"50px\" alt=\"robjtede\" style=\"max-width: 100%;\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/timheuer\"\u003e\u003cimg src=\"https://github.com/timheuer.png\" width=\"50px\" alt=\"robjtede\" style=\"max-width: 100%;\"\u003e\u003c/a\u003e\n\n\n## License\n\ncRonstrue is freely distributable under the terms of the [MIT license](https://github.com/bradymholt/cronstrue/blob/main/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbradymholt%2Fcronstrue","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbradymholt%2Fcronstrue","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbradymholt%2Fcronstrue/lists"}