Unminify PHP Code

Got PHP squeezed onto one line? This page expands it back into separate statements, with braces on their own lines and each block indented. Variable names are not restored, and comments that were removed are gone for good, but the structure becomes easy to follow.

How to unminify PHP

  1. 1

    Paste the one-line code

    Copy the compressed PHP into the PHP code box.

  2. 2

    Choose the indent

    Select 2 or 4 spaces. Four spaces is easier to scan for deep nesting.

  3. 3

    Continue to the result

    The expanded code appears on the next page.

  4. 4

    Check and copy

    Read through it, then copy it into your editor.

What unminifying can and cannot do

Minifiers remove whitespace and comments, and some also shorten names. Expanding the layout is the easy part: a statement ends at a semicolon, a block starts and ends at a brace. This tool uses exactly those markers. It cannot bring back removed comments, original variable names or original formatting choices.

Example

Compressed input:

<?php if($age>=18){echo "adult";}else{echo "minor";}

Expanded result:

<?php if($age>=18)
{
    echo "adult";
}
else
{
    echo "minor";
}

The tool also adds a space after each comma, so ["red","green"] becomes ["red", "green"]. This applies to commas in the code, not only between arguments.

Limits to keep in mind

  • Strings that contain commas, such as "a,b", also get a space added after the comma, because that rule runs over the whole text before the code is read. Check text literals afterwards.
  • A semicolon or brace inside a comment is treated as code and starts a new line there.
  • Spacing around operators stays as it was. If the minified source wrote $a+$b, the result does too.
  • Obfuscated code that uses encoded strings or evaluated payloads stays unreadable even when laid out neatly. Treat unknown code with care and never run it just to see what it does.

Reading the result

Start with the outermost braces, which are now at the left edge, and work inward. Function and class headers show what the code defines, and the indented lines under them show what each piece does. Long chains of statements that were run together are now one per line, so you can follow the order in which things happen.

Tips for working with compressed code

  • Format first, then read. Do not edit the compressed text directly.
  • Keep the original file. The expanded layout is for reading, and your editor’s formatter can restyle it later.
  • If a file has several top-level functions, paste them together. Each ends at its closing brace, which makes the boundaries easy to see.

Compare against the original

If you still have the minified file, search it for a few unusual strings and confirm they appear in the expanded text. This is a quick way to confirm nothing was lost, and it is worth doing before you copy the result anywhere important.

Frequently Asked Questions

No. Names shortened by a minifier are lost. Only the layout is rebuilt.

No. Once comments are removed from the source, there is nothing to restore.

It should be for simple code, since only whitespace changes. Comma spacing inside string literals is the main exception, so check strings.

No. It only changes layout. Encoded or packed payloads stay as they are.

Related Tools

Tool available in other languages

Guides and use cases