PHPackages                             michalskoula/remove-formatting - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. michalskoula/remove-formatting

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

michalskoula/remove-formatting
==============================

Simple tool to remove (some) HTML formatting, for example for text copied from Word or Google Docs.

1.0.1(1y ago)16MITPHPPHP &gt;=7.4

Since Sep 17Pushed 1y ago1 watchersCompare

[ Source](https://github.com/MichalSkoula/remove-formatting)[ Packagist](https://packagist.org/packages/michalskoula/remove-formatting)[ RSS](/packages/michalskoula-remove-formatting/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (3)Used By (0)

Remove Formatting
=================

[](#remove-formatting)

Simple tool to remove (some) HTML formatting, for example for text copied from Microsoft Word or Google Docs. It removes unwanted styles, classes, elements etc.

Features:

- removes unwanted elements (default: keep \['a', 'img', 'p', 'strong'\])
- removes unwanted attributes (default: keep \['href', 'src'\])
- removes unwanted whitespaces (default: false)

Installation
------------

[](#installation)

```
composer require michalskoula/remove-formatting
```

Requires PHP 7.4+

Usage
-----

[](#usage)

```
use MichalSkoula\RemoveFormatting\Remover;
use MichalSkoula\RemoveFormatting\RemoverOptions;

// create options object (optional)
$options = new RemoverOptions();

// add  to the default list of allowed elements
$options->addAllowedElement('u');

// add class to the default list of allowed attributes
$options->addAllowedAttribute('class');

// create Remover object
$remover = new Remover($options);

$dirtyHtml = 'some dirty spans ...';

// run it and get clean html with only allowed elements and attributes
$cleanHtml = $remover->remove($dirtyHtml);
```

See example.php

### HTML Before

[](#html-before)

```
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
Phasellus rhoncus. Quisque porta. Maecenas libero. Sed vel lectus. Donec odio tempus molestie, porttitor ut, iaculis quis, sem. Integer tempor. Fusce wisi.

Nullam at arcu a est sollicitudin euismod.
Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos.
Sed ac dolor sit
amet purus malesuada congue. Etiam dictum tincidunt diam. Aenean vel massa quis mauris vehicula lacinia.
```

### HTML After

[](#html-after)

```
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus rhoncus. Quisque porta. Maecenas libero. Sed vel lectus. Donec odio tempus molestie, porttitor ut, iaculis quis, sem. Integer tempor. Fusce wisi.

Nullam at arcu a est sollicitudin euismod.Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos.

Sed ac dolor sit amet purus malesuada congue. Etiam dictum tincidunt diam. Aenean vel massa quis mauris vehicula lacinia.
```

About
-----

[](#about)

- MIT Licence
-

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance43

Moderate activity, may be stable

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

599d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6b1cba9b39971b242a8755251edccfc2ec601ac29eb1b076ba6f404315aa1bc9?d=identicon)[MichalSkoula](/maintainers/MichalSkoula)

---

Top Contributors

[![MichalSkoula](https://avatars.githubusercontent.com/u/5922575?v=4)](https://github.com/MichalSkoula "MichalSkoula (4 commits)")

###  Code Quality

Static AnalysisRector

Code StyleECS

### Embed Badge

![Health badge](/badges/michalskoula-remove-formatting/health.svg)

```
[![Health](https://phpackages.com/badges/michalskoula-remove-formatting/health.svg)](https://phpackages.com/packages/michalskoula-remove-formatting)
```

###  Alternatives

[tzfrs/googlesitemapparser

Google Sitemap is a Sitemap standard that is supported by Ask.com, Google, YAHOO and MSN Search. This library can read in such Sitemaps and parse all urls from them.

143.3k](/packages/tzfrs-googlesitemapparser)[lrobert/gravatar

A library to make working with Gravatar in PHP easy.

101.4k](/packages/lrobert-gravatar)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
