PHP Code Formatter

Format and beautify PHP code following PSR-12 style using Prettier’s PHP plugin – right in your browser.

Tool

Was this tool useful?

About this tool

About PHP Code Formatter

Clean up messy PHP with consistent indentation, spacing and braces. Syntax errors are reported with the line number.

How it works

Powered by Prettier with @prettier/plugin-php, which formats code close to the PSR-12 standard.

Example

if($a){echo 'x';} becomes a neatly indented if block with spaces around the condition and the echo on its own line.

How to use this tool

  1. Paste your PHP code, including the opening PHP tag.
  2. Choose the indent size, line width and brace style.
  3. Click Format and copy the tidy code.

Frequently asked questions

Is my code uploaded?

No. Everything runs in your browser, so your code and data stay on your device.

Will it change what my code does?

No. Prettier only changes formatting, not behaviour. Old array() syntax is converted to short [] syntax.

Does the PHP Code Formatter send my data to a server?

No. The PHP Code Formatter runs entirely in your browser using JavaScript, so tokens, code and data you paste stay on your device. You can even use it offline once the page has loaded.