Format
Rewrites your PHP with Prettier and its PHP plugin. It fixes indentation, spacing, and line breaks so the code follows one clean, consistent style.
function greet($n){return 'Hi '.$n;}Afterfunction greet($n)
{
return 'Hi ' . $n;
}Paste messy PHP and get it back clean and easy to read. The formatter follows the common PSR-12 style and runs in your browser, so your code stays on your device.
Format uses Prettier with the PHP plugin. Options apply to Format.
The formatter reads your PHP and rewrites it in a clean, consistent style. It fixes indentation, tidies spacing around operators and brackets, puts braces where PSR-12 expects them, and wraps long lines to fit your width. It changes only the layout, never what the script does.
Rewrites your PHP with Prettier and its PHP plugin. It fixes indentation, spacing, and line breaks so the code follows one clean, consistent style.
function greet($n){return 'Hi '.$n;}Afterfunction greet($n)
{
return 'Hi ' . $n;
}Choose 2 or 4 spaces per level. PHP code most often uses 4 spaces, following the PSR-12 coding standard, but you can pick whichever your project prefers.
Mixed or no indentationAfterEven, consistent indentationPrefer single quotes for strings, and set the line width the formatter wraps at. Long calls and arrays break across lines to stay within the width you pick.
Long line, mixed quotesAfterWrapped, consistent quotesA formatter helps whenever you have PHP that is hard to read or does not match your project's style. These are the cases that come up most:
When you need to check how a function works or look up a piece of syntax, the PHP Manual is the reference to keep open. It covers the whole language and every built-in function.
The layout this tool produces comes from PSR-12, the coding standard most PHP teams agree on, applied by the Prettier PHP plugin. Read either one to see the rules behind the output.
If you work across languages, these formatters run the same way, right in your browser: