Tested tool guide
Tested browser tools
Checked August 16, 2026
What PHP Formatter (PSR-12) does, with a checked example
Paste PHP source into this tool and it rewrites only the whitespace to follow PSR-12, the PHP-FIG extended coding style guide: four-space indentation, class and method braces on their own line, control-structure braces on the same line as the keyword, and spaces around operators. Strings and comments pass through unchanged. The usual surprise is how little the tool does: it cannot repair syntax errors, add a missing visibility keyword, or convert double quotes to single quotes, and switching to tabs or same-line braces quietly steps outside PSR-12.
Worked example
A concrete input and expected output from the current implementation.
Input
<?php
namespace App;
class Greeter{
public function greet(string $who):string{
return "Hello, ".$who;
}
public function farewell():string{
return "Goodbye!";
}
} ->
Expected output
<?php
namespace App;
class Greeter
{
public function greet(string $who): string
{
return "Hello, " . $who;
}
public function farewell(): string
{
return "Goodbye!";
}
} The class and method opening braces move to their own line, the body indents by four spaces, spaces appear around the concatenation operator and after the return-type colon, and blank lines are inserted where PSR-12 requires them: after the namespace declaration and between methods. The strings, the parameter list, and the identifiers are preserved exactly.