PureDevTools

PHP Code Formatter & Beautifier

Format PHP code with PSR-12 compliant style — all in your browser, nothing sent to any server

All processing happens in your browser. No data is sent to any server.
Indent:
Braces:
Formatted Output

Formatted PHP will appear here.

A WordPress plugin file with 400 lines of PHP — mixed HTML and PHP blocks, inconsistent brace placement, and tabs-vs-spaces chaos. Before you can understand the plugin’s hook registration and filter logic, you need consistent formatting that reveals the code structure.

What Is a PHP Formatter?

A PHP formatter takes PHP source code and restructures it according to PSR-12 (the PHP Standards Recommendation for coding style). It normalizes indentation, brace placement, spacing around operators and control structures, and the organization of use declarations. Whether you’re working with Laravel, Symfony, WordPress, or plain PHP scripts, a formatter brings the code to a consistent, readable standard.

This tool supports:

PSR-12 Key Rules

PSR-12 is the current PHP coding style standard, extending PSR-2:

Common Use Cases

WordPress development: WordPress codebases often mix WordPress’s own coding standards with PSR-12. Format to your chosen standard before submitting pull requests.

Laravel/Symfony projects: Modern PHP frameworks follow PSR-12 strictly. Format code before commits to pass CI style checks.

Legacy PHP modernization: Older PHP 5.x codebases often have inconsistent formatting. Reformatting is the first step toward modernizing legacy code.

Code review: Consistent formatting eliminates style-only review comments, letting reviewers focus on logic, security, and architecture.

Frequently Asked Questions

Does this handle PHP 8 features like named arguments? Yes. PHP 8+ features including named arguments (array_slice(array: $arr, length: 3)), union types (int|string), match expressions, attributes (#[Route("/api")]), and constructor property promotion are formatted correctly.

Can it format mixed PHP and HTML? The formatter handles PHP code blocks. Files mixing PHP and HTML (<?php ... ?> interleaved with HTML) are partially supported — the PHP portions are formatted while HTML content is preserved.

Does it handle arrow functions? Yes. PHP 7.4+ arrow functions (fn($x) => $x * 2) are formatted with proper spacing around the => operator.

Is my PHP code sent to a server? No. All formatting runs entirely in your browser using JavaScript. No code is transmitted anywhere. Your source code never leaves your device.

Related Tools

More Code Formatters