PHP Formatter
Reformat PHP source in your browser. PSR-12-friendly defaults, brace-style toggle, opener normalization.
How to use
- 1 Paste PHP source.
- 2 Pick brace style and indent size.
- 3 Toggle whether to normalize short opening tags.
- 4 Copy or download the result.
Why use this tool
- No client-side PHP parser exists — this is a rule-based reformatter that handles braces and indent reliably.
- PSR-12 friendly defaults: K&R braces, 4-space indent.
- Pure client-side — your code never leaves the browser.
- For an authoritative format, run <code class="rounded bg-slate-100 px-1 text-xs dark:bg-slate-800">vendor/bin/pint</code> or <code class="rounded bg-slate-100 px-1 text-xs dark:bg-slate-800">php-cs-fixer</code> locally.
Frequently asked questions
Is this PSR-12 compliant?
It produces output close to PSR-12 (K&R braces, 4-space indent) but does not enforce every rule — line wrapping, import order, and method-spacing rules are not applied. For full PSR-12 use Pint or PHP-CS-Fixer.
Will it touch my HTML in templates?
It only reindents lines that contain PHP. Mixed HTML/PHP files may lose indentation inside the HTML sections — use a Blade-aware formatter for templates.
Looking for an HTML formatter?
Yes — see our <a href="/html-formatter" class="underline">HTML Formatter</a>.
PHP Formatter is a free developer utility by Zerethon Tools. Reformat PHP source in your browser. PSR-12-friendly defaults, brace-style toggle, opener normalization. Runs entirely in the browser — no signup, no upload.
- Category
- Developer
- Pricing
- Free
- Privacy
- Browser-based
- Signup
- Not required
Privacy
Your data never leaves your browser unless explicitly stated. PHP Formatter runs entirely client-side — no server upload, no logging, no tracking of your input.
Related tools
JSON Formatter
Format, validate, and minify JSON online. Free, no signup — your data never leaves your browser.
Open toolSQL Formatter
Format SQL queries online — beautify MySQL, PostgreSQL, SQLite, SQL Server, Oracle, and BigQuery.
Open toolUUID Generator
Generate UUIDs online — v1, v4, v7, and Nil. Bulk generation up to 10,000. Free, no signup.
Open toolPassword Generator
Generate strong, cryptographically random passwords. Configurable length and character sets — runs in your browser.
Open toolBuild, share, and grow on Zerethon Social
Free signup. Earn points, collect achievements, and connect with creators worldwide.