A code formatter is an automated tool that rewrites source code according to a defined set of formatting rules, covering areas such as indentation, spacing, line breaks and the placement of braces. The aim is to make code more consistent and readable without changing its behaviour.
Automating formatting removes much of the time spent making purely stylistic changes by hand. It also gives teams a consistent code style and keeps formatting discussions out of code reviews.
This roundup selects the best free and open source formatting tools for PHP developers.
Here’s our verdict captured in a legendary LinuxLinks-style ratings chart. Only free and open source software is eligible for inclusion.

Click the links in the table below to learn more about each tool.
| PHP Code Formatters | |
|---|---|
| PHP Coding Standards Fixer | Fix coding style issues automatically |
| Mago | Fast linting, style checking and static analysis |
| PHP_CodeSniffer | Detect violations of defined coding standards |
| pretty-php | Apply consistent, opinionated source styling |
Explore our carefully curated directory of recommended free and open source software, covering every major software category.The directory forms part of our extensive collection of articles for Linux enthusiasts. It includes hundreds of detailed reviews, together with free and open source alternatives to proprietary software from companies such as Google, Microsoft, Apple, Adobe, IBM, Cisco, Oracle, and Autodesk. LinuxLinks also covers interesting projects worth exploring, Linux-compatible hardware, free programming books and tutorials, and much more. Know a useful free and open source Linux application that we haven’t covered? Tell us about it using our submission form. |


Please read our Comment Policy before commenting.