Skip to content

Function: htmlToText()

htmlToText(html): string

Reduce a full HTML document to readable plain text: drop <script> / <style> / <noscript> blocks and comments, turn block-level tags into newlines, strip the remaining tags, decode entities, and collapse runs of blank lines / trailing spaces. Unlike htmlFragmentToText, this preserves line structure because paragraph breaks carry meaning in a page.

string

string