PHP Formatter
Format and validate PHP code online for free, right in your browser.
Local browser processing
No sign-up required
Supports modern PHP syntax
LanguageFor PHP code
PHPinput.php
Indent
⌘⏎Quick format
InputEditable
1
2
3
4
5
6
7
8
9
10
11
OutputPHP valid11 lines · 226 B
1
2
3
4
5
6
7
8
9
10
11
<?php
class UserService
{
public function __construct(private readonly UserRepository $repo) {}
public function findActive(): array
{
return array_filter($this->repo->all(), fn($u) => $u->active);
}
}
UTF-8 · Indent: 2 spacesLocal processing · Ready
How It WorksPHP
Overview
This PHP formatter cleans up code with inconsistent indentation or mixed styles into a unified style, powered by the Prettier PHP plugin's real syntax parser. Classes, interfaces, enums, match expressions, and other modern syntax are all correctly recognized. Everything runs locally in your browser; your data never leaves your device.
Use Cases
Unify a team's PHP code styleClean up code minified onto a single lineCheck whether class and function syntax is correctFormat code pasted from docs or generated by AI
Steps
123
Paste or uploadAdjust format optionsGet the result