Quickly & Easily clean out HTML text, making sure that only the bare minimum is left behind
timgws/cleanhtml is a Laravel package for quickly & easily clean out html text, making sure that only the bare minimum is left behind.
It currently has 6 GitHub stars and 115 downloads on Packagist.
Install it with composer require timgws/cleanhtml.
Discover more Laravel packages by timgws
or browse all Laravel packages to compare alternatives.
Last updated
Making HTML clean since late 2012!
composer require timgws/cleanhtml
use timgws\CleanHTML\CleanHTML;
$tidy = new CleanHTML();
$output = $tidy->clean('<p><strong>I need a shower. I am dirty HTML.</strong>');
$output should now contain:
<h2>I need a shower. I am dirty HTML.</h2>
Using the Clean function will remove tables, any Javascript or other non-friendly items that you might not want to see from user submitted HTML.
If you want to see some examples, the best place to look would be some of the CleanHTML test
<br /> tags with paragraph tags<script> tags<h1> tags to <h2><p><strong> tags to <h2><h2><strong> with just <h2> tags<p><span> tags