Format PHP code
Paste PHP code squeezed onto one line or poorly indented: the tool re-indents each { } block and puts one statement per line, for instant readability before you study or rework it.
Note: this is a basic indentation formatter, not a full tool like PHP-CS-Fixer. It does not check that the code is valid and does not reorganize the spacing around every operator.
How it works
The code is scanned character by character by a small state machine that distinguishes code from strings (single and double quotes) and comments (//, #, /* */), so it never splits a brace or semicolon that appears inside a string. Each opening brace increases the indentation by 4 spaces, each closing brace decreases it, and each semicolon outside parentheses ends a line.
Can the reformatted code stop working?
No: only the presentation changes (spaces, line breaks, indentation), never the logic of the PHP code. The contents of strings and comments are preserved as is.
Are <?php tags and mixed HTML handled?
The <?php tag is kept as is. However, if your file heavily mixes HTML and PHP (templates), indentation focuses on the PHP blocks and does not reorganize the surrounding HTML structure.
Formatting runs 100% locally in your browser: your PHP code is never sent to a server.