PHP Code Formatter
Format and beautify PHP code with consistent indentation. Free online PHP beautifier.
Input PHP
→
Formatted Output
About This Tool
The PHP Code Formatter beautifies PHP source code by applying consistent indentation and normalizing spacing. Paste minified, compressed, or poorly indented PHP and get clean, readable output in seconds.
All formatting runs entirely in your browser — no PHP code is sent to any server. Your source code stays private. For full PSR-12 compliance, use PHP-CS-Fixer; this tool is best for quick on-the-go reformatting.
How to Use
- Paste your PHP code into the Input area, or click Sample to load an example.
- Choose your preferred indent size: 2 or 4 spaces (PSR-12 standard is 4).
- Click Format to apply indentation.
- Review the formatted output, then click Copy to copy it to your clipboard.
Use Cases
The PHP formatter is used to read minified code from deployment bundles, standardize formatting in legacy codebases, deobfuscate PHP scripts for security research, and reformat code when an IDE is unavailable.
FAQ
- Does this follow PSR-12 standards? — This tool applies consistent brace-based indentation, which aligns with PSR-12 structure. For full compliance including line length limits and operator spacing, use PHP-CS-Fixer.
- Can it handle PHP mixed with HTML? — Yes, the formatter preserves HTML sections and only reindents lines within PHP blocks.
- Is my code sent to a server? — No. All processing happens in your browser using JavaScript. Your PHP code never leaves your device.