{"_id":"hast-util-to-string","_rev":"3991814","name":"hast-util-to-string","description":"hast utility to get the plain-text value of a node","dist-tags":{"latest":"3.0.1"},"maintainers":[{"name":"kmck","email":"keith@mcknig.ht"},{"name":"remcohaszing","email":""},{"name":"wooorm","email":"tituswormer@gmail.com"}],"time":{"modified":"2025-09-01T02:09:53.000Z","created":"2016-09-08T13:13:00.890Z","3.0.1":"2024-09-27T11:49:09.914Z","3.0.0":"2023-08-30T15:19:57.527Z","2.0.0":"2021-08-01T19:05:42.114Z","1.0.4":"2020-07-02T11:12:16.074Z","1.0.3":"2020-03-21T18:27:49.538Z","1.0.2":"2019-06-01T13:39:39.102Z","1.0.1":"2017-07-24T20:52:52.962Z","1.0.0":"2016-09-08T13:13:00.890Z"},"users":{},"author":{"name":"Titus Wormer","email":"tituswormer@gmail.com","url":"https://wooorm.com"},"repository":{"type":"git","url":"git+https://github.com/rehypejs/rehype-minify.git#main"},"versions":{"3.0.1":{"name":"hast-util-to-string","version":"3.0.1","description":"hast utility to get the plain-text value of a node","license":"MIT","keywords":["content","hast","hast-util","html","serialize","string","stringify","text","unist","util","utility"],"repository":{"type":"git","url":"git+https://github.com/rehypejs/rehype-minify.git#main"},"bugs":{"url":"https://github.com/rehypejs/rehype-minify/issues"},"funding":{"type":"opencollective","url":"https://opencollective.com/unified"},"author":{"name":"Titus Wormer","email":"tituswormer@gmail.com","url":"https://wooorm.com"},"contributors":[{"name":"Titus Wormer","email":"tituswormer@gmail.com"}],"sideEffects":false,"type":"module","exports":"./index.js","dependencies":{"@types/hast":"^3.0.0"},"scripts":{},"typeCoverage":{"atLeast":100,"detail":true,"ignoreCatch":true,"strict":true},"xo":{"prettier":true,"rules":{"capitalized-comments":"off"}},"_id":"hast-util-to-string@3.0.1","gitHead":"79383ba769010ff52c547c57850d2dd3ecb815a9","types":"./index.d.ts","homepage":"https://github.com/rehypejs/rehype-minify/tree/main#readme","_nodeVersion":"22.7.0","_npmVersion":"10.8.3","dist":{"shasum":"a4f15e682849326dd211c97129c94b0c3e76527c","size":3918,"noattachment":false,"key":"/hast-util-to-string/-/hast-util-to-string-3.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/hast-util-to-string/download/hast-util-to-string-3.0.1.tgz"},"_npmUser":{"name":"wooorm","email":"tituswormer@gmail.com"},"directories":{},"maintainers":[{"name":"kmck","email":"keith@mcknig.ht"},{"name":"remcohaszing","email":""},{"name":"wooorm","email":"tituswormer@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/hast-util-to-string_3.0.1_1727437749697_0.6877321866354471"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2024-09-27T11:49:09.914Z","publish_time":1727437749914,"_source_registry_name":"default","_cnpm_publish_time":1727437749914},"3.0.0":{"name":"hast-util-to-string","version":"3.0.0","description":"hast utility to get the plain-text value of a node","license":"MIT","keywords":["content","hast","hast-util","html","serialize","string","stringify","text","unist","util","utility"],"repository":{"type":"git","url":"git+https://github.com/rehypejs/rehype-minify.git#main"},"bugs":{"url":"https://github.com/rehypejs/rehype-minify/issues"},"funding":{"type":"opencollective","url":"https://opencollective.com/unified"},"author":{"name":"Titus Wormer","email":"tituswormer@gmail.com","url":"https://wooorm.com"},"contributors":[{"name":"Titus Wormer","email":"tituswormer@gmail.com"}],"sideEffects":false,"type":"module","exports":"./index.js","dependencies":{"@types/hast":"^3.0.0"},"scripts":{},"typeCoverage":{"atLeast":100,"detail":true,"ignoreCatch":true,"strict":true},"xo":false,"_id":"hast-util-to-string@3.0.0","gitHead":"142a16cf75ea59ab9a32b1a38e02cc42cdca3f6d","types":"./index.d.ts","homepage":"https://github.com/rehypejs/rehype-minify/tree/main#readme","_nodeVersion":"20.5.1","_npmVersion":"9.8.0","dist":{"shasum":"2a131948b4b1b26461a2c8ac876e2c88d02946bd","size":3027,"noattachment":false,"key":"/hast-util-to-string/-/hast-util-to-string-3.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/hast-util-to-string/download/hast-util-to-string-3.0.0.tgz"},"_npmUser":{"name":"wooorm","email":"tituswormer@gmail.com"},"directories":{},"maintainers":[{"name":"kmck","email":"keith@mcknig.ht"},{"name":"remcohaszing","email":""},{"name":"wooorm","email":"tituswormer@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/hast-util-to-string_3.0.0_1693408797318_0.8710555321332674"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2023-08-30T15:19:57.527Z","publish_time":1693408797527,"_source_registry_name":"default","_cnpm_publish_time":1693408797527},"2.0.0":{"name":"hast-util-to-string","version":"2.0.0","description":"hast utility to get the plain-text value of a node","license":"MIT","keywords":["unist","hast","hast-util","util","utility","html","string","serialize","content","stringify","text"],"repository":{"type":"git","url":"git+https://github.com/rehypejs/rehype-minify.git#main"},"bugs":{"url":"https://github.com/rehypejs/rehype-minify/issues"},"funding":{"type":"opencollective","url":"https://opencollective.com/unified"},"author":{"name":"Titus Wormer","email":"tituswormer@gmail.com","url":"https://wooorm.com"},"contributors":[{"name":"Titus Wormer","email":"tituswormer@gmail.com"}],"sideEffects":false,"type":"module","main":"index.js","types":"index.d.ts","dependencies":{"@types/hast":"^2.0.0"},"scripts":{"build":"rimraf \"*.d.ts\" && tsc && type-coverage","test":"node --conditions development test.js"},"xo":false,"typeCoverage":{"atLeast":100,"detail":true,"strict":true,"ignoreCatch":true},"homepage":"https://github.com/rehypejs/rehype-minify/tree/main#readme","_id":"hast-util-to-string@2.0.0","_nodeVersion":"16.2.0","_npmVersion":"7.18.1","dist":{"shasum":"b008b0a4ea472bf34dd390b7eea1018726ae152a","size":2146,"noattachment":false,"key":"/hast-util-to-string/-/hast-util-to-string-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/hast-util-to-string/download/hast-util-to-string-2.0.0.tgz"},"_npmUser":{"name":"wooorm","email":"tituswormer@gmail.com"},"directories":{},"maintainers":[{"name":"kmck","email":"keith@mcknig.ht"},{"name":"remcohaszing","email":""},{"name":"wooorm","email":"tituswormer@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/hast-util-to-string_2.0.0_1627844741994_0.486401634927917"},"_hasShrinkwrap":false,"publish_time":1627844742114,"_cnpm_publish_time":1627844742114},"1.0.4":{"name":"hast-util-to-string","version":"1.0.4","description":"hast utility to get the plain-text value of a node","license":"MIT","keywords":["unist","hast","hast-util","util","utility","html","string","serialize","content","stringify","text"],"repository":{"type":"git","url":"https://github.com/rehypejs/rehype-minify/tree/main/packages/hast-util-to-string"},"bugs":{"url":"https://github.com/rehypejs/rehype-minify/issues"},"funding":{"type":"opencollective","url":"https://opencollective.com/unified"},"author":{"name":"Titus Wormer","email":"tituswormer@gmail.com","url":"https://wooorm.com"},"contributors":[{"name":"Titus Wormer","email":"tituswormer@gmail.com"}],"xo":false,"_id":"hast-util-to-string@1.0.4","_nodeVersion":"14.0.0","_npmVersion":"6.14.5","dist":{"shasum":"9b24c114866bdb9478927d7e9c36a485ac728378","size":1687,"noattachment":false,"key":"/hast-util-to-string/-/hast-util-to-string-1.0.4.tgz","tarball":"http://registry.cnpm.dingdandao.com/hast-util-to-string/download/hast-util-to-string-1.0.4.tgz"},"maintainers":[{"name":"kmck","email":"keith@mcknig.ht"},{"name":"remcohaszing","email":""},{"name":"wooorm","email":"tituswormer@gmail.com"}],"_npmUser":{"name":"wooorm","email":"tituswormer@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/hast-util-to-string_1.0.4_1593688335928_0.7531685266107948"},"_hasShrinkwrap":false,"publish_time":1593688336074,"_cnpm_publish_time":1593688336074},"1.0.3":{"name":"hast-util-to-string","version":"1.0.3","description":"hast utility to get the plain-text value of a node","license":"MIT","keywords":["unist","hast","hast-util","util","utility","html","string","serialize","content","stringify","text"],"repository":{"type":"git","url":"https://github.com/rehypejs/rehype-minify/tree/master/packages/hast-util-to-string"},"bugs":{"url":"https://github.com/rehypejs/rehype-minify/issues"},"funding":{"type":"opencollective","url":"https://opencollective.com/unified"},"author":{"name":"Titus Wormer","email":"tituswormer@gmail.com","url":"https://wooorm.com"},"contributors":[{"name":"Titus Wormer","email":"tituswormer@gmail.com"}],"xo":false,"_id":"hast-util-to-string@1.0.3","_nodeVersion":"13.10.1","_npmVersion":"6.14.3","dist":{"shasum":"897d4bbd0dc7a9b0765a943a82fa38136277de1f","size":1687,"noattachment":false,"key":"/hast-util-to-string/-/hast-util-to-string-1.0.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/hast-util-to-string/download/hast-util-to-string-1.0.3.tgz"},"maintainers":[{"name":"kmck","email":"keith@mcknig.ht"},{"name":"remcohaszing","email":""},{"name":"wooorm","email":"tituswormer@gmail.com"}],"_npmUser":{"name":"wooorm","email":"tituswormer@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/hast-util-to-string_1.0.3_1584815269447_0.05033004430967458"},"_hasShrinkwrap":false,"publish_time":1584815269538,"_cnpm_publish_time":1584815269538},"1.0.2":{"name":"hast-util-to-string","version":"1.0.2","description":"hast utility to get the plain-text value of a node","license":"MIT","keywords":["unified","rehype","hast","string"],"repository":{"type":"git","url":"https://github.com/rehypejs/rehype-minify/tree/master/packages/hast-util-to-string"},"bugs":{"url":"https://github.com/rehypejs/rehype-minify/issues"},"author":{"name":"Titus Wormer","email":"tituswormer@gmail.com","url":"https://wooorm.com"},"contributors":[{"name":"Titus Wormer","email":"tituswormer@gmail.com"}],"xo":false,"_id":"hast-util-to-string@1.0.2","_nodeVersion":"12.2.0","_npmVersion":"6.9.0","dist":{"shasum":"fcf6d46bde2a50a1fbcaf6ed238971a51b622eac","size":1653,"noattachment":false,"key":"/hast-util-to-string/-/hast-util-to-string-1.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/hast-util-to-string/download/hast-util-to-string-1.0.2.tgz"},"maintainers":[{"name":"kmck","email":"keith@mcknig.ht"},{"name":"remcohaszing","email":""},{"name":"wooorm","email":"tituswormer@gmail.com"}],"_npmUser":{"name":"wooorm","email":"tituswormer@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/hast-util-to-string_1.0.2_1559396378971_0.18147980396290464"},"_hasShrinkwrap":false,"publish_time":1559396379102,"_cnpm_publish_time":1559396379102},"1.0.1":{"name":"hast-util-to-string","version":"1.0.1","description":"Get the plain-text value of a node","license":"MIT","keywords":["rehype","hast","string"],"repository":{"type":"git","url":"https://github.com/wooorm/rehype-minify/tree/master/packages/hast-util-to-string"},"bugs":{"url":"https://github.com/wooorm/rehype-minify/issues"},"author":{"name":"Titus Wormer","email":"tituswormer@gmail.com","url":"http://wooorm.com"},"contributors":[{"name":"Titus Wormer","email":"tituswormer@gmail.com"}],"files":["index.js"],"xo":false,"_id":"hast-util-to-string@1.0.1","_npmVersion":"5.1.0","_nodeVersion":"8.1.2","_npmUser":{"name":"wooorm","email":"tituswormer@gmail.com"},"dist":{"shasum":"b28055cdca012d3c8fd048757c8483d0de0d002c","size":1106,"noattachment":false,"key":"/hast-util-to-string/-/hast-util-to-string-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/hast-util-to-string/download/hast-util-to-string-1.0.1.tgz"},"maintainers":[{"name":"kmck","email":"keith@mcknig.ht"},{"name":"remcohaszing","email":""},{"name":"wooorm","email":"tituswormer@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/hast-util-to-string-1.0.1.tgz_1500929572901_0.38714815746061504"},"directories":{},"publish_time":1500929572962,"_cnpm_publish_time":1500929572962,"_hasShrinkwrap":false},"1.0.0":{"name":"hast-util-to-string","version":"1.0.0","description":"Get the plain-text value of a node","license":"MIT","keywords":["rehype","hast","string"],"repository":{"type":"git","url":"https://github.com/wooorm/rehype-minify/tree/master/packages/hast-util-to-string"},"bugs":{"url":"https://github.com/wooorm/rehype-minify/issues"},"author":{"name":"Titus Wormer","email":"tituswormer@gmail.com","url":"http://wooorm.com"},"contributors":[{"name":"Titus Wormer","email":"tituswormer@gmail.com"}],"files":["index.js"],"_id":"hast-util-to-string@1.0.0","scripts":{},"_shasum":"16c07671f0f2ac7735e455cdae32c7c1b8963f2a","_from":".","_npmVersion":"3.10.6","_nodeVersion":"6.3.0","_npmUser":{"name":"wooorm","email":"tituswormer@gmail.com"},"dist":{"shasum":"16c07671f0f2ac7735e455cdae32c7c1b8963f2a","size":911,"noattachment":false,"key":"/hast-util-to-string/-/hast-util-to-string-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/hast-util-to-string/download/hast-util-to-string-1.0.0.tgz"},"maintainers":[{"name":"kmck","email":"keith@mcknig.ht"},{"name":"remcohaszing","email":""},{"name":"wooorm","email":"tituswormer@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/hast-util-to-string-1.0.0.tgz_1473340379253_0.7403443849179894"},"directories":{},"publish_time":1473340380890,"_cnpm_publish_time":1473340380890,"_hasShrinkwrap":false}},"readme":"<!--This file is generated-->\n\n# hast-util-to-string\n\n[![Build][build-badge]][build]\n[![Coverage][coverage-badge]][coverage]\n[![Downloads][downloads-badge]][downloads]\n[![Size][size-badge]][size]\n[![Sponsors][funding-sponsors-badge]][funding]\n[![Backers][funding-backers-badge]][funding]\n[![Chat][chat-badge]][chat]\n\n[`hast`][hast] utility to get the plain-text value of a node.\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  * [`toString(node)`](#tostringnode)\n* [Syntax](#syntax)\n* [Syntax tree](#syntax-tree)\n* [Types](#types)\n* [Compatibility](#compatibility)\n* [Security](#security)\n* [Contribute](#contribute)\n* [License](#license)\n\n## What is this?\n\nThis package is a utility to get the plain-text value of a node.\n\n## When should I use this?\n\nYou can use this package when you want to get the plain text value of a node.\nThe algorithm used by this package is like the DOMs `Node#textContent`\ngetter.\n\nTo use the DOMs `Node#innerText` algorithm instead, use\n[`hast-util-to-text`](https://github.com/syntax-tree/hast-util-to-text).\n`innerText` is aware of how things are displayed, for example turning hard\nbreaks (`<br>`) into line endings.\n\n## Install\n\nThis package is [ESM only][esm].\nIn Node.js (version 16+), install with [npm][]:\n\n```sh\nnpm install hast-util-to-string\n```\n\nIn Deno with [`esm.sh`][esm-sh]:\n\n```js\nimport {toString} from 'https://esm.sh/hast-util-to-string@3'\n```\n\nIn browsers with [`esm.sh`][esm-sh]:\n\n```html\n<script type=\"module\">\n  import {toString} from 'https://esm.sh/hast-util-to-string@3?bundle'\n</script>\n```\n\n## Use\n\n```js\nimport {h} from 'hastscript'\nimport {toString} from 'hast-util-to-string'\n\ntoString(h('p', 'Alpha'))\n//=> 'Alpha'\ntoString(h('div', [h('b', 'Bold'), ' and ', h('i', 'italic'), '.']))\n//=> 'Bold and italic.'\n```\n\n## API\n\nThis package exports the identifier\n`toString`.\nThere is no default export.\n\n### `toString(node)`\n\nGet the plain-text value of a node.\n\n###### Parameters\n\n* `node` (`Node`) — node to serialize\n\n###### Returns\n\nSerialized node (`string`).\n\n## Syntax\n\nHTML is parsed according to WHATWG HTML (the living standard), which is also\nfollowed by all browsers.\n\n## Syntax tree\n\nThe syntax tree used is [hast][].\n\n## Types\n\nThis package is fully typed with [TypeScript][].\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-to-string@^3`,\ncompatible with Node.js 16.\n\n## Security\n\nAs **rehype** works on HTML and improper use of HTML can open you up to a\n[cross-site scripting (XSS)][xss] attack, use of rehype can also be unsafe.\nUse [`rehype-sanitize`][rehype-sanitize] to make the tree safe.\n\n## Contribute\n\nSee [`contributing.md`][contributing] in [`rehypejs/.github`][health] for ways\nto 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[author]: https://wooorm.com\n\n[build]: https://github.com/rehypejs/rehype-minify/actions\n\n[build-badge]: https://github.com/rehypejs/rehype-minify/workflows/main/badge.svg\n\n[chat]: https://github.com/rehypejs/rehype/discussions\n\n[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg\n\n[coc]: https://github.com/rehypejs/.github/blob/main/code-of-conduct.md\n\n[contributing]: https://github.com/rehypejs/.github/blob/main/contributing.md\n\n[coverage]: https://codecov.io/github/rehypejs/rehype-minify\n\n[coverage-badge]: https://img.shields.io/codecov/c/github/rehypejs/rehype-minify.svg\n\n[downloads]: https://www.npmjs.com/package/hast-util-to-string\n\n[downloads-badge]: https://img.shields.io/npm/dm/hast-util-to-string.svg\n\n[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c\n\n[esm-sh]: https://esm.sh\n\n[funding]: https://opencollective.com/unified\n\n[funding-backers-badge]: https://opencollective.com/unified/backers/badge.svg\n\n[funding-sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg\n\n[hast]: https://github.com/syntax-tree/hast\n\n[health]: https://github.com/rehypejs/.github\n\n[license]: https://github.com/rehypejs/rehype-minify/blob/main/license\n\n[npm]: https://docs.npmjs.com/cli/install\n\n[rehype-sanitize]: https://github.com/rehypejs/rehype-sanitize\n\n[size]: https://bundlejs.com/?q=hast-util-to-string\n\n[size-badge]: https://img.shields.io/bundlejs/size/hast-util-to-string\n\n[support]: https://github.com/rehypejs/.github/blob/main/support.md\n\n[typescript]: https://www.typescriptlang.org\n\n[xss]: https://en.wikipedia.org/wiki/Cross-site_scripting\n","_attachments":{},"homepage":"https://github.com/rehypejs/rehype-minify/tree/main#readme","bugs":{"url":"https://github.com/rehypejs/rehype-minify/issues"},"license":"MIT"}