Use html2text (example HTML to text), licensed under the Eclipse Public License. It uses PHP's DOM methods to load from HTML, and then iterates over the resulting DOM to extract plain text. Usage:
// when installed using the Composer package $text = Html2TextHtml2Text::convert($html); // usage when installed using html2text.php require('html2text.php'); $text = convert_html_to_text($html);
Although incomplete, it is open source and contributions are welcome.
Issues with other conversion scripts:
- Since html2text (GPL) is not EPL-compatible.
- lkessler's link (attribution) is incompatible with most open source licenses.