PHPackages                             machy8/xhtml-formatter - 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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. machy8/xhtml-formatter

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

machy8/xhtml-formatter
======================

Simple, lightweight, customizable (X)HTML and XML formatter / beautifier.

v1.0.0(8y ago)13188.0k↓48.2%25New BSD LicensePHPPHP &gt;=7.0

Since Aug 14Pushed 8y ago2 watchersCompare

[ Source](https://github.com/Machy8/xhtml-formatter)[ Packagist](https://packagist.org/packages/machy8/xhtml-formatter)[ RSS](/packages/machy8-xhtml-formatter/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (2)Versions (2)Used By (5)

XML + (X)HTML formatter / beautifier
====================================

[](#xml--xhtml-formatter--beautifier)

[![Build Status](https://camo.githubusercontent.com/166018929093feb7a73f19f4959d67180a774fbe200c071d3be1e9c5a1e958b5/68747470733a2f2f7472617669732d63692e6f72672f4d61636879382f7868746d6c2d666f726d61747465722e7376673f6272616e63683d302e31)](https://travis-ci.org/Machy8/xhtml-formatter)

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

[](#installation)

```
composer require machy8/xhtml-formatter

```

Usage
-----

[](#usage)

Compiles this 💩

```
>

    title

```

into this 😱😭

```
>

			title

```

and all you need is

```
use XhtmlFormatter\Formatter;

$formatter = new Formatter();

$output = $formatter->format($string);
```

and if you want to disable formatting

```

			Unformatted code goes here!

```

Setup
-----

[](#setup)

```
$formatter

	// Change the content type from CONTENT_HTML (default) to CONTENT_XML or CONTENT_XHTML
	->setContentType(Formatter::CONTENT_XML)

	// Add new unpaired element
	->addUnpairedElement('element', Formatter::CONTENT_XML)

	// Add skipped elements
	->addSkippedElement('elementA elementB')

	// Indent file by 4 spaces instead of tabs
	->setSpacesIndentationMethod(4);
```

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity40

Moderate usage in the ecosystem

Community17

Small or concentrated contributor base

Maturity58

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

Unknown

Total

1

Last Release

3245d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/14016808?v=4)[Vladimír Macháček](/maintainers/Machy8)[@Machy8](https://github.com/Machy8)

---

Top Contributors

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

---

Tags

beautifierformatterhtmlxhtmlxmlformatterxmlhtmlxhtmlbeautifier

### Embed Badge

![Health badge](/badges/machy8-xhtml-formatter/health.svg)

```
[![Health](https://phpackages.com/badges/machy8-xhtml-formatter/health.svg)](https://phpackages.com/packages/machy8-xhtml-formatter)
```

###  Alternatives

[masterminds/html5

An HTML5 parser and serializer.

1.8k269.7M322](/packages/masterminds-html5)[imangazaliev/didom

Simple and fast HTML parser

2.2k2.5M72](/packages/imangazaliev-didom)[querypath/querypath

HTML/XML querying and processing (like jQuery)

8367.1M27](/packages/querypath-querypath)[rumenx/php-sitemap

Framework-agnostic Sitemap generator for PHP, Laravel, and Symfony.

1.3k26.9k1](/packages/rumenx-php-sitemap)[rct567/dom-query

DomQuery is a PHP library that allows easy 'jQuery like' DOM traversing and manipulation

136269.4k4](/packages/rct567-dom-query)[gravitypdf/querypath

PHP library for HTML(5)/XML querying (CSS 4 or XPath) and processing (like jQuery) with PHP 7.1 to 8.5 support

301.5M1](/packages/gravitypdf-querypath)

PHPackages © 2026

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