PHP Formatter & Minifier
PHP formatter that tidies functions, if/else blocks and loops with proper indentation, or minifies PHP by stripping comments and wasted space.
PHP Formatter & Minifier tool
Formatting PHP, step by step
- Paste your PHP, or press Load sample.
- Choose an indent and press Beautify.
- Copy the output or save it as a
.phpfile.
How the formatter works
It splits statements at semicolons and opens a new indented block at each {, so functions, classes, if/else branches and loops line up the way they nest. It is aimed at the common case of reading PHP that got squashed onto one line or lost its indentation in an email, a forum post or a database field. Single- and double-quoted strings are protected first, so a string containing ;, { or // comes out unchanged.
Minify
Minify removes /* */, // and # comments and collapses whitespace. Use it for short snippets that must fit somewhere small. For a whole project, keep the readable source in version control instead.
Limitations
- Opening braces go on their own line (Allman style). If your project follows PSR-12, where control-structure braces stay on the same line, run your project's own formatter (PHP-CS-Fixer, for instance) before committing.
- Templates heavy with HTML and PHP tags are better handled by the HTML formatter.
- Heredoc and nowdoc strings are not protected, so check them after formatting.
PHP Formatter & Minifier at a glance
PHP formatter: beautify messy PHP into clean, indented code or minify it, with string-safe processing. Free PHP beautifier and minifier.
- Cost
- Free to use, with no account, watermark or usage cap.
- Privacy
- Processing happens on your device; nothing is sent to our servers.
- Devices
- Up-to-date Chrome, Edge, Firefox or Safari on computers, Android phones and iPhones.
- Last updated
Frequently asked questions
Are strings left untouched?
Yes. Single- and double-quoted strings are shielded while formatting, so text containing braces or slashes is unchanged.
What about files mixing HTML and PHP?
Simple mixed files are fine, but the tool is designed for PHP blocks. Templates heavy with HTML are better handled by the HTML formatter.
Is my PHP uploaded?
No. Everything is processed in your browser, so the code stays private.