There is no license information available for the latest version (dev-master) of this package.

Working horse HTML to text convertor for PHP. Years of finding right choice

dev-master 2015-12-13 13:58 UTC

This package is not auto-updated.

Last update: 2020-01-19 13:28:25 UTC


Convert html to text, filter html tags, purify html. Best and most advanced html to text conversion library for php.

Used Htmlpurifier



"ezyang/htmlpurifier": "dev-master",
"sunra/html_to_text": "dev-master"

to required section in you composer.json


// Total remove tags. br converted to new lines
$plain_text = \Sunra\HtmlToText\HtmlToText::plain_text( $html );

// removed all tags but safest 'br,b,strong,li,ol,ul'
$safe_html = \Sunra\HtmlToText\HtmlToText::safe_html( $html );

// remove unsafe code (XSS attacks) and heals html - close tags etc
$purified_html = \Sunra\HtmlToText\HtmlToText::purify( $html );

// Remove all tags but allowed (coma separated - for example 'br,b')
$purified_html = \Sunra\HtmlToText\HtmlToText::filter( $html, $allowed_tags );