PHP source restore (formatter)
Re-format PHP that php-compress flattened: `<?php` / `?>` on their own lines, line breaks after `;` and `{}`, indentation by brace depth, and `} else {`, `} elseif {`, `} catch {` kept on one line. Strings and heredoc bodies stay untouched. The indent size is configurable and the round-trip is semantically equivalent (only whitespace changes).
Runs in your browserEvery computation happens in your browser — your data never leaves this device.
Result
The result can be copied directly.
Paste compressed PHP source to restore the layout
Characters: 0 · Lines: 0 · Statements: 0 · Final indent depth: 0
What this tool does
- Turn a one-line inline PHP snippet back into a readable structure.
- Compare compressed and restored code to confirm no semantic change.
- Normalise indentation of PHP snippets across a team.
Example
Input
<?php declare(strict_types=1);class A{public function f(): int{return 1;}}echo (new A())->f();Output
<?php
declare(strict_types=1);
class A {
public function f(): int {
return 1;
}
}
echo (new A())->f();Restoring only adjusts whitespace and line breaks; it does not invent comments or rename identifiers. Use version control to get stripped comments back.
Frequently asked questions
Is the output byte-identical to the original?
Whitespace is re-laid-out and comments are not restored, so it is not byte-identical; statements, strings and heredoc bodies match, so behaviour is the same.
Will `} else {` be split across lines?
No. When `}` is followed by else / elseif / catch / finally / while it stays on the same line, matching common PHP style.
Can I use 2 spaces or tabs?
The indent size is configurable from 0 to 8 and uses spaces (PSR-12 uses 4). There is no tab option.
What happens with invalid input?
Whitespace-only input or an indent outside 0–8 throws invalid-input / invalid-number with a clear message in the UI.
Keywords:php uncompress