PHP Formatter

Free PHP formatter and beautifier: format messy PHP code with clean indentation, and see the number of lines, functions, classes and variables.

  • 100% free
  • No sign-up
  • Runs in your browser

Webmaster Tools

About the PHP Formatter

The PHP Formatter tidies PHP code with consistent indentation and spacing so it is easier to read and review. It also counts the lines, functions, classes and variables in your code.

Everything runs in your browser, so your text or code never leaves your device. That makes it safe for code that includes settings you would not paste into an online service.

How to use this tool

  1. 1Paste your PHP code.
  2. 2Read the formatted result.
  3. 3Copy it back into your editor.

Best-practice tips

  • Format code before reviewing or editing it.
  • For larger projects, set up an automatic formatter in your editor so every file follows the same style.
  • Never share real passwords or keys in code you paste online elsewhere.

Readable code is safer code

Consistent indentation makes mistakes such as a missing brace or a misplaced condition much easier to spot. For WordPress themes and plugins, tidy code also makes updates and fixes quicker. For HTML in your templates, use the HTML Formatter.

Answers

PHP Formatter FAQs

It re-indents and spaces PHP code consistently so it is easy to read. It does not change what the code does.

Related tools

Continue with these related webmaster tools.