hast-util-from-string

JSON →
library 3.0.1 ·javascript
verified May 27, 2026

hast-util-from-string is a utility package within the unified and rehype ecosystem designed to efficiently set the plain-text value of a HAST (Hypertext Abstract Syntax Tree) node. It mimics the behavior of the DOM's `Node#textContent` setter, effectively replacing all children of a node with a single text node containing the provided string value. The current stable version is 3.0.1. As part of the unified collective, it follows a coordinated release cadence, often aligning major version bumps across related packages, though individual utilities receive minor and patch updates as needed. A key differentiator is its `textContent`-like behavior, contrasting with `hast-util-from-text` which emulates `innerText` and considers rendering specifics like line breaks and table cell separation. The library is ESM-only and fully typed with TypeScript.

total hits 14
actors 6 distinct systems
last hit 4d ago AhrefsBot
MetaBot
4
GPTBot
2
Script
1
Search engines
1

top countries 🇺🇸 United States · 🇨🇦 Canada · 🇳🇴 Norway · 🇫🇷 France · 🇩🇪 Germany