jsonecho

PHP Formatter

Format PHP code with consistent indentation and spacing.

Loading the tool...

How to use PHP Formatter

  1. Paste your code. The formatter engine loads in a moment the first time.
  2. Adjust the options if you need to.
  3. Copy the formatted result.

About PHP Formatter

This formatter parses your PHP and prints it back in a tidy, consistent style: indentation, spacing around operators, one statement per line and wrapped long argument lists. Modern syntax such as arrow functions, match expressions, enums and attributes is supported.

The engine loads the first time you use the page, which takes a moment. After that it runs locally.

Frequently asked questions

Does it follow PSR-12?

It follows a style close to PSR-12, with 4 spaces, though it is not a PSR-12 compliance checker.

Does it run my PHP?

No. The code is parsed as text. Nothing is executed and nothing is sent to a server.

Which PHP versions are supported?

Syntax up to a recent PHP 8 release is understood. Very new syntax may not be covered yet.

Does it need the opening tag?

Start with <?php. Without it the text is treated as plain HTML output.

Why did the first run take a second?

The formatting engine for this language is downloaded the first time you use it, then cached by your browser. After that, formatting is instant and nothing leaves your machine.

More in Code Formatters

All tools →