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
- 1Paste your PHP code.
- 2Read the formatted result.
- 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.
No. It is formatted in your browser.
Yes, with no sign-up.
Related tools
Continue with these related webmaster tools.
Meta Tag Generator
Free meta tag generator: create your title tag, meta description, robots and canonical tags with a live Google search preview and character counter.
View Page Source
Free page source viewer: see the HTML source code of any website with line numbers, a search filter and tag counts. Works on any device, including phones.
XML Sitemap Generator
Free XML sitemap generator: crawl your website (up to 5,000 pages) or paste a URL list and download a valid sitemap.xml. Leaves out redirects, errors and noindex pages.