Contact Us

PHP Code-Beautifier Tool

Posted on 1/5/07 by Tim Koschützki

Today I discovered a good tool for beautifying existing PHP Code. It works via a web interface. You can either upload a script or directly input it. The code is beautified according to the PHP PEAR Standard Requirements. It does not change or debug your code in any way. What it does is the following:

* Tries to set missing curly braces around single conditional statements. This may not work in all situations.
* Indents with four spaces.
* Uses "one true brace" style in function definitions.
* Sets one space between control keyword and condition.
* Removes space between function calls, parenthesis and beginning of argument list.

Nice tool!

You can download it here.


You can skip to the end and add a comment.

[...], there’s a new post pointing out a code beautification tool Tim dug up the (aptly named) “PHP Code [...]

medyk said on May 12, 2007:

It has one big flaw.. it works in iso-8859-1 encoding instead of utf-8 - it will change all non iso characters in code..

Tim Koschuetzki said on May 15, 2007:

Yeah checked that out myself. I will most likely email the developer about it.

Other than that it's a good tool!

Bidfreelancers said on May 31, 2007:

Can it work on all php files in one folder or we have to upload one file by file.

Tim Koschuetzki said on May 31, 2007:

Unfortunately it can't yet. However, I will modify it so that it will be possible. I scheduled this for Sunday. Can't work on it today, because I will need to do something for my full-time job. :/

Visitor302 said on Aug 05, 2007:

Your site found in Google:

kvz said on Jul 29, 2008:

Another one is PHP_Beautifier. Not perfect, but might help in some cases:

pear install PHP_Beautifier
# note: you may need to first run

pear config-set preferred_state beta

php_beautifier \
--filters "\

IndentStyles(style=k&r) \

NewLines(before=if:switch:T_CLASS,after=function) \

Pear(add_header=apache) \

ArrayNested() \


-f myfile.php

This post is too old. We do not allow comments here anymore in order to fight spam. If you have real feedback or questions for the post, please contact us.