PHP Formatter
Beautify PHP code following PSR-style formatting with the Prettier PHP plugin.
About the PHP Formatter
The PHP Formatter uses the Prettier PHP plugin to produce consistent, PSR-style code: braces, spacing and line breaks are normalised so diffs only show real changes.
Everything runs in your browser, so your input is never uploaded to a server.
How to use the PHP Formatter
- Paste PHP code (with or without the opening <?php tag) or open a file.
- Choose indentation.
- Copy or download the formatted code.
Frequently asked questions
Is the output PSR-12 compliant?
It follows PSR-style conventions for layout. Rules that need semantic changes (such as naming) are not applied.
Does it run my PHP code?
No. The code is only parsed and formatted in your browser; use the PHP Compiler to run it.
Related tools
JSON Formatter
Format and beautify JSON with configurable indentation and optional key sorting. Errors are reported with exact line and column.
HTML Formatter
Beautify messy or minified HTML into clean, indented markup using Prettier, right in your browser.
CSS Formatter
Format CSS, SCSS and Less stylesheets into readable, consistently indented code.
JavaScript Formatter
Beautify JavaScript and JSX with Prettier. Choose indentation, quotes and semicolons.
TypeScript Formatter
Format TypeScript and TSX code with Prettier, including types, generics and decorators.
SQL Formatter
Format SQL queries for MySQL, PostgreSQL, SQLite, SQL Server and more with keyword casing options.