Skip to content

PHP Formatter

Format PHP code with Prettier and the official PHP plugin, PSR-12 style, with a target PHP version setting.

Runs in your browserPHP → PHP
Loading tool…

Example

Input
<?php
function add($a,$b){return $a+$b;}
echo add(1,2);
Output
<?php
function add($a, $b)
{
    return $a + $b;
}
echo add(1, 2);

How to use the PHP Formatter

  1. Include the opening <?php tag. Files that mix HTML and PHP are supported.
  2. Pick the oldest PHP version your code must run on; newer versions allow trailing commas in multi-line calls.

Privacy and limitations

  • Your data is processed on your device and is not uploaded to any server.
  • Code must parse as valid PHP for the selected version; syntax errors are reported with a line number.
  • HTML outside <?php ?> blocks is kept as-is rather than reformatted.

Browse all beautifiers & formatters →