{"id":13583141,"url":"https://github.com/syntax-tree/hast-util-reading-time","last_synced_at":"2026-02-03T19:14:08.648Z","repository":{"id":57261740,"uuid":"405093564","full_name":"syntax-tree/hast-util-reading-time","owner":"syntax-tree","description":"utility to estimate the reading time","archived":false,"fork":false,"pushed_at":"2023-08-08T12:38:31.000Z","size":56,"stargazers_count":57,"open_issues_count":0,"forks_count":2,"subscribers_count":8,"default_branch":"main","last_synced_at":"2026-01-29T21:27:41.593Z","etag":null,"topics":["estimate","hast","hast-util","html","readability","reading","reading-time","time","unist"],"latest_commit_sha":null,"homepage":"https://unifiedjs.com","language":"JavaScript","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/syntax-tree.png","metadata":{"funding":{"github":"unifiedjs","open_collective":"unified"},"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"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}},"created_at":"2021-09-10T13:39:26.000Z","updated_at":"2025-08-09T21:54:23.000Z","dependencies_parsed_at":"2024-04-08T17:08:42.991Z","dependency_job_id":null,"html_url":"https://github.com/syntax-tree/hast-util-reading-time","commit_stats":{"total_commits":20,"total_committers":2,"mean_commits":10.0,"dds":"0.050000000000000044","last_synced_commit":"52d2184ced5ed8990f73b9f76617f9a90c435d0c"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/syntax-tree/hast-util-reading-time","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Fhast-util-reading-time","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Fhast-util-reading-time/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Fhast-util-reading-time/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Fhast-util-reading-time/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/syntax-tree","download_url":"https://codeload.github.com/syntax-tree/hast-util-reading-time/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Fhast-util-reading-time/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29054202,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-03T15:43:47.601Z","status":"ssl_error","status_checked_at":"2026-02-03T15:43:46.709Z","response_time":96,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["estimate","hast","hast-util","html","readability","reading","reading-time","time","unist"],"created_at":"2024-08-01T15:03:16.860Z","updated_at":"2026-02-03T19:14:07.734Z","avatar_url":"https://github.com/syntax-tree.png","language":"JavaScript","readme":"# hast-util-reading-time\n\n[![Build][build-badge]][build]\n[![Coverage][coverage-badge]][coverage]\n[![Downloads][downloads-badge]][downloads]\n[![Size][size-badge]][size]\n[![Sponsors][sponsors-badge]][collective]\n[![Backers][backers-badge]][collective]\n[![Chat][chat-badge]][chat]\n\n[hast][] utility to estimate the reading time, taking readability of the\ndocument into account.\n\n## Contents\n\n*   [What is this?](#what-is-this)\n*   [When should I use this?](#when-should-i-use-this)\n*   [Install](#install)\n*   [Use](#use)\n*   [API](#api)\n    *   [`readingTime(tree[, options])`](#readingtimetree-options)\n    *   [`Options`](#options)\n*   [Types](#types)\n*   [Compatibility](#compatibility)\n*   [Security](#security)\n*   [Related](#related)\n*   [Contribute](#contribute)\n*   [License](#license)\n\n## What is this?\n\nThis package is a utility that takes a [hast][] (HTML) syntax tree and estimates\nthe reading time, taking readability of the document and a target age group into\naccount.\n\n## When should I use this?\n\nThis is a small utility useful when you have an AST, know your audience, and\nwant a really smart reading time algorithm.\n\nThe rehype plugin\n[`rehype-infer-reading-time-meta`][rehype-infer-reading-time-meta]\nwraps this utility to figure, for use with [`rehype-meta`][rehype-meta].\n\n## Install\n\nThis package is [ESM only][esm].\nIn Node.js (version 16.0+), install with [npm][]:\n\n```sh\nnpm install hast-util-reading-time\n```\n\nIn Deno with [`esm.sh`][esmsh]:\n\n```js\nimport {readingTime} from 'https://esm.sh/hast-util-reading-time@2'\n```\n\nIn browsers with [`esm.sh`][esmsh]:\n\n```html\n\u003cscript type=\"module\"\u003e\n  import {readingTime} from 'https://esm.sh/hast-util-reading-time@2?bundle'\n\u003c/script\u003e\n```\n\n## Use\n\nSay our document `example.html` contains (from [“Word per minute: Alphanumeric\nentry” on Wikipedia][wiki]:\n\n```html\n\u003cp\u003eSince the length or duration of words is clearly variable, for the purpose of measurement of text entry, the definition of each \"word\" is often standardized to be five characters or keystrokes long in English, including spaces and punctuation. For example, under such a method applied to plain English text the phrase \"I run\" counts as one word, but \"rhinoceros\" and \"let's talk\" would both count as two.\u003c/p\u003e\n\u003cp\u003eKarat et al. found that one study of average computer users in 1999, the average rate for transcription was 32.5 words per minute, and 19.0 words per minute for composition. In the same study, when the group was divided into \"fast\", \"moderate\", and \"slow\" groups, the average speeds were 40 wpm, 35 wpm, and 23 wpm, respectively.\u003c/p\u003e\n\u003cp\u003eWith the onset of the era of desktop computers, fast typing skills became much more widespread.\u003c/p\u003e\n\u003cp\u003eAn average professional typist types usually in speeds of 43 to 80 wpm, while some positions can require 80 to 95 (usually the minimum required for dispatch positions and other time-sensitive typing jobs), and some advanced typists work at speeds above 120 wpm. Two-finger typists, sometimes also referred to as \"hunt and peck\" typists, commonly reach sustained speeds of about 37 wpm for memorized text and 27 wpm when copying text, but in bursts may be able to reach much higher speeds. From the 1920s through the 1970s, typing speed (along with shorthand speed) was an important secretarial qualification and typing contests were popular and often publicized by typewriter companies as promotional tools.\u003c/p\u003e\n```\n\n…and our module `example.js` looks as follows:\n\n```js\nimport fs from 'node:fs/promises'\nimport {fromHtml} from 'hast-util-from-html'\nimport {readingTime} from 'hast-util-reading-time'\n\nconst tree = fromHtml(await fs.readFile('example.html'), {fragment: true})\n\nconsole.log(\n  `It takes about ${Math.ceil(readingTime(tree, {age: 18}))}-${Math.ceil(readingTime(tree, {age: 14}))}m to read`\n)\n```\n\n…now running `node example.js` yields:\n\n```txt\nIt takes about 2-3m to read\n```\n\n## API\n\nThis package exports the identifier [`readingTime`][api-reading-time].\nThere is no default export.\n\n### `readingTime(tree[, options])`\n\nEstimate the reading time, taking readability of the document and a target age\ngroup into account.\n\nFor some more background info/history and a few insight on where this all comes\nfrom, see [How estimated reading times increase content engagement][martech].\n\n###### Algorithm\n\nThe algorithm works as follows:\n\n*   estimate the WPM (words per minute) of the audience age based on the facts\n    that English can be read at ±228 WPM (Trauzettel-Klosinski), and that\n    reading rate increases 14 WPM per grade (Carver)\n*   apply the readability algorithms [Dale—Chall][dale-chall],\n    [Automated Readability][automated-readability], [Coleman-Liau][],\n    [Flesch][], [Gunning-Fog][], [SMOG][], and [Spache][]\n*   adjust the WPM of the audience for whether the readability algorithms\n    estimate its above or below their level\n*   `wordCount / adjustedWpm = readingTime`\n\n\u003e ⚠️ **Important**: this algorithm is specific to English.\n\n###### Parameters\n\n*   `tree` ([`Node`][node])\n    — tree to inspect\n*   `options` ([`Options`][api-options], optional)\n    — configuration\n\n###### Returns\n\nEstimated reading time in minutes (`number`).\n\nThe result is not rounded so it’s possible to retrieve estimated seconds from\nit.\n\n### `Options`\n\nConfiguration (TypeScript type).\n\n##### Fields\n\n###### `age`\n\nTarget age group (`number`, default: `16`).\n\nThis is the age your target audience was still in school.\nSet it to 18 if you expect all readers to have finished high school, 21 if you\nexpect your readers to all be college graduates, etc.\n\n## Types\n\nThis package is fully typed with [TypeScript][].\nIt exports the additional type [`Options`][api-options].\n\n## Compatibility\n\nProjects maintained by the unified collective are compatible with maintained\nversions of Node.js.\n\nWhen we cut a new major release, we drop support for unmaintained versions of\nNode.\nThis means we try to keep the current release line,\n`hast-util-reading-time@^2`, compatible with Node.js 16.\n\n## Security\n\nUse of `hast-util-reading-time` is safe.\n\n## Related\n\n*   [`rehype-infer-reading-time-meta`][rehype-infer-reading-time-meta]\n    — infer reading time as file metadata from the document\n*   [`rehype-meta`][rehype-meta]\n    — add metadata to the head of a document\n\n## Contribute\n\nSee [`contributing.md`][contributing] in [`syntax-tree/.github`][health] for\nways to get started.\nSee [`support.md`][support] for ways to get help.\n\nThis project has a [code of conduct][coc].\nBy interacting with this repository, organization, or community you agree to\nabide by its terms.\n\n## License\n\n[MIT][license] © [Titus Wormer][author]\n\n\u003c!-- Definitions --\u003e\n\n[build-badge]: https://github.com/syntax-tree/hast-util-reading-time/workflows/main/badge.svg\n\n[build]: https://github.com/syntax-tree/hast-util-reading-time/actions\n\n[coverage-badge]: https://img.shields.io/codecov/c/github/syntax-tree/hast-util-reading-time.svg\n\n[coverage]: https://codecov.io/github/syntax-tree/hast-util-reading-time\n\n[downloads-badge]: https://img.shields.io/npm/dm/hast-util-reading-time.svg\n\n[downloads]: https://www.npmjs.com/package/hast-util-reading-time\n\n[size-badge]: https://img.shields.io/badge/dynamic/json?label=minzipped%20size\u0026query=$.size.compressedSize\u0026url=https://deno.bundlejs.com/?q=hast-util-reading-time\n\n[size]: https://bundlejs.com/?q=hast-util-reading-time\n\n[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg\n\n[backers-badge]: https://opencollective.com/unified/backers/badge.svg\n\n[collective]: https://opencollective.com/unified\n\n[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg\n\n[chat]: https://github.com/syntax-tree/unist/discussions\n\n[npm]: https://docs.npmjs.com/cli/install\n\n[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c\n\n[esmsh]: https://esm.sh\n\n[typescript]: https://www.typescriptlang.org\n\n[license]: license\n\n[author]: https://wooorm.com\n\n[health]: https://github.com/syntax-tree/.github\n\n[contributing]: https://github.com/syntax-tree/.github/blob/main/contributing.md\n\n[support]: https://github.com/syntax-tree/.github/blob/main/support.md\n\n[coc]: https://github.com/syntax-tree/.github/blob/main/code-of-conduct.md\n\n[hast]: https://github.com/syntax-tree/hast\n\n[node]: https://github.com/syntax-tree/hast#nodes\n\n[dale-chall]: https://github.com/words/dale-chall-formula\n\n[automated-readability]: https://github.com/words/automated-readability\n\n[coleman-liau]: https://github.com/words/coleman-liau\n\n[flesch]: https://github.com/words/flesch\n\n[gunning-fog]: https://github.com/words/gunning-fog\n\n[spache]: https://github.com/words/spache-formula\n\n[smog]: https://github.com/words/smog-formula\n\n[rehype-infer-reading-time-meta]: https://github.com/rehypejs/rehype-infer-reading-time-meta\n\n[rehype-meta]: https://github.com/rehypejs/rehype-meta\n\n[wiki]: https://en.wikipedia.org/wiki/Words_per_minute#Alphanumeric_entry\n\n[martech]: https://martech.org/estimated-reading-times-increase-engagement/\n\n[api-reading-time]: #readingtimetree-options\n\n[api-options]: #options\n","funding_links":["https://github.com/sponsors/unifiedjs","https://opencollective.com/unified"],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsyntax-tree%2Fhast-util-reading-time","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsyntax-tree%2Fhast-util-reading-time","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsyntax-tree%2Fhast-util-reading-time/lists"}