PHP Formatter — PSR-12 Beautifier for PHP Source Code
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>.
What is PHP Formatter?
A PHP Formatter is a tool that reformats PHP source code in the browser using PSR-12-friendly defaults. It offers a brace-style toggle and tag-opener normalization, reindenting code for consistent layout and readability. Because it runs entirely client-side, the source code stays on the user's device.
Features
Brace-depth reindent
Re-indents blocks by brace nesting and normalizes brace placement to K&R or Allman.
PSR-12-friendly defaults
Sensible 4-space indentation and short-tag normalization out of the box.
100% private
Runs client-side — your PHP is never uploaded.
Example
Input
<?php
if ($x)
{
echo 1;
}
Output
<?php
if ($x) {
echo 1;
}
Common use cases
-
1
Tidy pasted PHP
Fix indentation on a snippet copied from a log, email, or chat.
-
2
Normalize brace style
Convert between K&R and Allman brace placement across a block.
-
3
Quick readability pass
Improve layout before review without installing PHP-CS-Fixer locally.
Zerethon's PHP formatter reindents PHP source in your browser using PSR-12-friendly defaults, with a brace-style toggle (K&R or Allman) and short-tag normalization (`<?` → `<?php`). It is a lightweight brace-depth reindenter, not a full PHP-CS-Fixer — it tidies layout without reflowing long lines. Nothing is uploaded.
- Category
- Developer
- Pricing
- Free
- Privacy
- Browser-based
- Signup
- Not required
References
- PSR-12 — Extended Coding Style — PHP-FIG
- PHP Manual — php.net
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.