PHPackages                             purplebooth/twig-htmlstrip - 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. purplebooth/twig-htmlstrip

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

purplebooth/twig-htmlstrip
==========================

Convert a small subset of html into something reasonable you can put in plain text email, or SMS.

v1.2.0(8y ago)330.8k1[4 PRs](https://github.com/PurpleBooth/twig-htmlstrip/pulls)MITPHP

Since Feb 4Pushed 6y ago1 watchersCompare

[ Source](https://github.com/PurpleBooth/twig-htmlstrip)[ Packagist](https://packagist.org/packages/purplebooth/twig-htmlstrip)[ RSS](/packages/purplebooth-twig-htmlstrip/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (7)Dependencies (6)Versions (12)Used By (0)

twig-htmlstrip
==============

[](#twig-htmlstrip)

Filter for Twig to convert a small subset of html into something reasonable you can put in plain text email, or SMS.

[![Build Status](https://camo.githubusercontent.com/94abd926aebe562f9f084e5507bb603c9cdae98f6efaae9a615e85b7d93116ad/68747470733a2f2f7472617669732d63692e6f72672f507572706c65426f6f74682f747769672d68746d6c73747269702e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/PurpleBooth/twig-htmlstrip)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/be9a03158eab53f5260ccd4841e3a8fa54c6e3858d1be1c7e5d92de5f15c85c9/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f507572706c65426f6f74682f747769672d68746d6c73747269702f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/PurpleBooth/twig-htmlstrip/?branch=master)[![Coverage Status](https://camo.githubusercontent.com/3221476f745602e259c95ca465b2bb14c2f3b3bce9feefd87f1f82b9ffedf80a/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f507572706c65426f6f74682f747769672d68746d6c73747269702f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/PurpleBooth/twig-htmlstrip?branch=master)[![Dependency Status](https://camo.githubusercontent.com/c46454ba35fa3b1bbef0c57f93a26e3f0d67e6bf4ca835e38f2f11a1a2c4b125/68747470733a2f2f7777772e76657273696f6e6579652e636f6d2f757365722f70726f6a656374732f3537393532343739623465383663303034633333333866372f62616467652e7376673f7374796c653d666c61742d737175617265)](https://www.versioneye.com/user/projects/57952479b4e86c004c3338f7)[![Latest Stable Version](https://camo.githubusercontent.com/1df8480e9f717bde90f891fcfcab0e480f19b4840ed177527b564bb791346807/68747470733a2f2f706f7365722e707567782e6f72672f707572706c65626f6f74682f747769672d68746d6c73747269702f762f737461626c65)](https://packagist.org/packages/purplebooth/twig-htmlstrip)[![Total Downloads](https://camo.githubusercontent.com/f49ce62ba3c21163ea8ac73532fc562f17c0a630bb4c8b6349b41729ec26c3c8/68747470733a2f2f706f7365722e707567782e6f72672f707572706c65626f6f74682f747769672d68746d6c73747269702f646f776e6c6f616473)](https://packagist.org/packages/purplebooth/twig-htmlstrip)[![License](https://camo.githubusercontent.com/2610b1d323ce66192e180af3221a2a5e4aba410607b38c2063b25402cd33397e/68747470733a2f2f706f7365722e707567782e6f72672f707572706c65626f6f74682f747769672d68746d6c73747269702f6c6963656e7365)](https://packagist.org/packages/purplebooth/twig-htmlstrip)

How To Use
----------

[](#how-to-use)

Add the dependency to your composer.json

```
php composer.phar require purplebooth/twig-htmlstrip:^1.0.0
```

Add a service which points to the class, and tag it with the twig.extension tag.

```
# src/Acme/DemoBundle/Resources/config/services.yml
services:
    purplebooth.twig.html_stripper_extension:
        class: PurpleBooth\HtmlStripperExtension
        tags:
            - { name: twig.extension }
```

And use it

```
{{ yourhtml|html_strip }}
```

Examples
--------

[](#examples)

Input:

```
Hello, world.
```

Output:

```
Hello, world.

```

Input:

```
Quote source
```

Output:

```
Quote source (http://pleasestopbeingsad.tumblr.com/)

```

Input:

```

    You're a good person
    Don't be too hard on yourself
    Enjoy the little things

```

Output:

```
* You're a good person
* Don't be too hard on yourself
* Enjoy the little things

```

Input:

```
Tomorrow will be better.
You're doing your best, and I'm proud of you.
```

Output:

```
Tomorrow will be better.

You're doing your best, and I'm proud of you.

```

Input:

```
It's always good to read a good book.
You are not here, but I am thinking of you.
```

Output:

```
It's always good to read a good book. You are not here, but I am thinking of you.

```

Input:

```

    If she wants to dance and drink all night.

        Well theres no one that can stop her
        Shes going until the house lights come up or her stomach spills on to the floor
        This night is gonna end when we're damn well ready for it to be over
        Worked all week long now the music is playing on our time

    HelloFin.

```

Output

```
If she wants to dance and drink all night.

* Well theres no one that can stop her
* Shes going until the house lights come up or her stomach spills on to the floor
* This night is gonna end when we're damn well ready for it to be over
* Worked all week long now the music is playing on our time

Hello

Fin.

```

Related
-------

[](#related)

- [Stand alone library](https://github.com/PurpleBooth/htmlstrip)

Versioning
----------

[](#versioning)

We use [semver](http://semver.org/). See the [releases](https://github.com/PurpleBooth/twig-htmlstrip/releases) for a changelog and versions

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 96.8% 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 ~210 days

Recently: every ~90 days

Total

7

Last Release

3266d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/133327?v=4)[Billie Thompson](/maintainers/PurpleBooth)[@PurpleBooth](https://github.com/PurpleBooth)

---

Top Contributors

[![PurpleBooth](https://avatars.githubusercontent.com/u/133327?v=4)](https://github.com/PurpleBooth "PurpleBooth (60 commits)")[![dependabot-support](https://avatars.githubusercontent.com/u/112581971?v=4)](https://github.com/dependabot-support "dependabot-support (1 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (1 commits)")

### Embed Badge

![Health badge](/badges/purplebooth-twig-htmlstrip/health.svg)

```
[![Health](https://phpackages.com/badges/purplebooth-twig-htmlstrip/health.svg)](https://phpackages.com/packages/purplebooth-twig-htmlstrip)
```

PHPackages © 2026

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