Time-Savers: Code Beautifier And Formatter


Well-documented and readable source code is essential for every collaborative project. Logically structured, well organized and nicely formatted, the code can speed up the bug hunting and help to keep the code clean, minimal and still functional. These aspects are particularly important if the code is being developed by a group of developers: in this context a common scheme for source code presentation is necessary. You don’t have to do everything by hand; in fact, there are many tools which can save a lot of time – for you and your co-workers.

The tools and services we’ve collected below aren’t validators. They format and beautify the code; some of them can remove redundant elements. Using them, you have to make sure you have a backup, so your data can always be restored.

Let’s take a look at code beautifier and formatter which can save you a lot of time and help to maintain a clean and readable source code.

Code Beautifier And Formatter Link

1. Quick Highlighter1
Quick Highlighter can format source codes written in over 85 languages – among them C++, PHP, Ruby, HTML, JavaScript, Perl, Python, Smarty, XML and more. The tool formats source code and highlights inbuilt keywords, data types etc.


2. PrettyPrinter3
Knows PHP, Java, C++, C, Perl, JavaScript, CSS. The service offers many formatting options you can use to present the code just the way you’d like it to look like.


3. PHP Code Beautifier5
This tool is designed to beautify PHP code, applying most of the PEAR standard requirements to it. It can even process really scrambled scripts, e.g. all code in one line, and thus may help you to get scripts into a more readable form. It sets missing line breaks without removing any additional line breaks that you may use to group related things and corrects wrong indentation according to the level of nested braces.

4. Ruby Script Beautifier6
Ruby Beautifier accepts a command-line list of file names, creates a backup copy of each named file and beautifies the originals. If there is an indentation error (an imbalance of opening and closing keywords), the script will print an error message but will save the result anyway.

5. Tabifier7
The tabifier is a tool to properly indent computer code. The style it produces is a mix of my personal preferences for indentation plus what I could manage to make a program produce from dirty source. The tabifier currently supports CSS, HTML, and C Style code; the latter being anything that uses curly braces to start and end blocks, and semicolons to terminate statements.


6. CSS Beautifier9
This tool offers a variety of options, among them – Alphabetizing Feature and De-Capitalization Feature.


7. CSS Formatierer und Optimierer11
Has different compression layouts; you can sort selectors, properties, regroup selectors, optimize shorthands, compress colors, compress font-weight, discard invalid properties and add timestamps. You can also create a custom template the system will use to format the code. The result can be outputted as a file. A copy / mirror of the tool can be found on cleancss.com12.


8. Highlight.js14
Highlight.js highlights syntax in code examples on blogs, forums and in fact on any web pages. It’s very easy to use because it works automatically: finds blocks of code, detects a language, highlights it. Also available as WordPress-Plugin and Firefox-extension. Suported languages: Python, Ruby, Perl, PHP, HTML, CSS, Django, JavaScript, VBScript, Delphi, Java, C++, SQL. Similar tools is offered by Google: Googles Javascript Code Prettifier15.


9. Code Beautifier Plus18
Beautifies Java, C# and ActionScript.


10. PHP Formatter20
PHP formatter adds comments after control structures, colors the output, links to the php-manual by inline-functions, removes comments and removes empty lines. There are 5 pre-defined layouts, but you can also define your own styles.


11. PHP_Beautifier22
A tool to beautify PHP 4 and PHP 5 source code – to run on your own server. Requires PHP 5.

12. Online Beautifier for JavaScript23
The tool completely reformats the JavaScript source code, so that it becomes a little bit more readable.

13. Lorins simple code beautifier for C++, C#, Java, and Javascript24
You can use the source code of this beautifier to creat your own code formatters.

14. Tidy25
A classic. Tidy consists of many program libraries and comes and has many variations. E.g. you can use


Commercial Solutions Link

15. SourceFormatX Source Code Formatter & Beautifier34
For developers. The tool supports neither HTML nor CSS; instead Javascript, VB, PHP, ASP, JSP, HTC, C, JAVA and more. Price: $36,99, Windows.


16. Polystyle36
Polystyle automatically reformats source code in your personal style. Polystyle learns your formatting style by examining examples of your code. It is another Windows-tool which supports Actionscript, ASP, C/C++, C#, CMAC, CSS, HTML, Java, Javascript, JSP, PHP, Pascal/Delphi, Perl, Python and Visual Basic. Price: 79$, can be used from the shell and Windows Explorer.

Further Solutions Link

17. phpCodeBeautifier37 (Win/Linux Shell), HTB 2.038 (Shell).

Footnotes Link

  1. 1 http://quickhighlighter.com/
  2. 2 http://quickhighlighter.com/
  3. 3 http://www.prettyprinter.de/
  4. 4 http://www.prettyprinter.de/
  5. 5 http://www.tote-taste.de/X-Project/beautify/
  6. 6 http://www.arachnoid.com/ruby/rubyBeautifier.html
  7. 7 http://tools.arantius.com/tabifier
  8. 8 http://tools.arantius.com/tabifier
  9. 9 http://www.lonniebest.com/FormatCSS/
  10. 10 http://www.lonniebest.com/FormatCSS/
  11. 11 http://cdburnerxp.se/cssparse/css_optimiser.php?lang=de
  12. 12 http://www.cleancss.com/?lang=de
  13. 13 http://cdburnerxp.se/cssparse/css_optimiser.php?lang=de
  14. 14 http://softwaremaniacs.org/soft/highlight/en/
  15. 15 http://google-code-prettify.googlecode.com/svn/trunk/README.html
  16. 16 http://softwaremaniacs.org/soft/highlight/en/
  17. 17 http://google-code-prettify.googlecode.com/svn/trunk/README.html
  18. 18 http://pluszone.net/blog/projects/beautifierPlus/index.php
  19. 19 http://pluszone.net/blog/projects/beautifierPlus/index.php
  20. 20 http://formatter.gerbenvv.nl/version3/index.php?lang=en
  21. 21 http://formatter.gerbenvv.nl/version3/index.php?lang=en
  22. 22 http://beautifyphp.sourceforge.net/docs/
  23. 23 http://elfz.laacz.lv/beautify/?
  24. 24 http://couponmeister.com/beautify.aspx
  25. 25 http://tidy.sourceforge.net/
  26. 26 http://perso.wanadoo.fr/ablavier/TidyGUI/
  27. 27 http://sourceforge.net/projects/tidy
  28. 28 http://www.w3.org/People/Raggett/tidy/
  29. 29 http://www.highdots.com/html-code-export/
  30. 30 http://csstidy.sourceforge.net/
  31. 31 http://perltidy.sourceforge.net/
  32. 32 http://users.skynet.be/mgueury/mozilla/index.html
  33. 33 http://tidy.sourceforge.net/
  34. 34 http://www.textrush.com/
  35. 35 http://www.textrush.com/
  36. 36 http://www.polystyle.com/
  37. 37 http://www.waterproof.fr/products/phpCodeBeautifier/
  38. 38 http://www.digital-mines.com/htb/

↑ Back to top Tweet itShare on Facebook

Sven is the co-founder and former CEO of Smashing Magazine. He's now writing at his Conterest Blog, where he focuses on blogs, content strategy and publishing — all in German.

  1. 1

    Better solution: (g)Vim with syntax highlighting.

  2. 2

    Some useful tools ! Thank you ! :)

  3. 3

    Ok, those are great. Has anyone seen a class library that performs code formatting for display in ASP.NET C#?

    I plan to use this on my blog to show code that I find useful.


  4. 4

    marianne mcdougall

    July 12, 2007 9:22 pm

    Some very useful tools – Thank a lot guys.

    G3 Creative (Scotland)

  5. 5

    I just use dreamweaver. It highlights code as well as anything Ive seen.

  6. 6

    I use a free piece of software (Windows only) called HTML-Kit. It offers highlighting for just about every web language, a vast repository of plugins, and a built in FTP client (very handy for editing things on the fly).

  7. 7

    I’m surprised Pygments was left off the list. For syntax highlighting, I don’t think it can be beat.

  8. 8

    Awesome tips as usual.
    Though I would recommend saving a backup copy prior to using the tools. I know that sometimes TIDY can toss my whole page into a column. But it is still a useful tool, just remember it is a tool.

  9. 9
  10. 10

    Thanks for this very helpful posting.

    I read about online backup on a daily dasis from an aggregator site,


    I have been trying to find a source code for making a sofware for online backup service. Do you know of any such codes?


  11. 11

    Is the javascript from google for prettifying code on webpages in this list?

  12. 12

    Karl L. Gechlik

    July 13, 2007 1:21 am

    I know some programers around here that can learn from this! I have forwarded it along. Thank you for the great article.

    Keep up the great work from your friends @ AskTheADmin

  13. 13

    In regards to #9. Code Beautifier Plus….you should be shot dead at your keyboard if you use on(press), etc in actionscript.

  14. 14


    July 13, 2007 2:00 am

    I’ve been using AStyle for years.


    Artistic Style 1.21
    A Free, Fast and Small Automatic Formatter
    for C, C++, C#, and Java Source Code

    Is that advertising?

  15. 15

    For SQL, wangz.net provides a really nice SQL Instant Formatter

  16. 16

    Anyone know of a Dreamweaver add-on that does this?

  17. 17
  18. 18

    Make sure that you test your app after applying the modifications. There are cases when code formatters have caused errors in the code.

    Also, make sure you have taken a backup before saving the formatted code.

  19. 19

    There is one more good commercial solution: Profactor Style Manager. This tool intergrates into VisualStudio and allows adjust all styles it can apply. Nice thing, I’ve used it once.

  20. 20

    There is a nice csstidy version (same as http://www.cleancss.com) at http://www.codebeautifier.com with a portuguese version and a ‘select code’ feature. :)

  21. 21

    As this post shows, c, c++, java, php, etc code formatters are about a dime a dozen.

    What I need is a free formatter for COBOL.

    That sure would make the task that I have to do SO much easier.

    Does anyone know of a good FREE COBOL code formatter?

  22. 22

    Seriously people, use Vim.

    It can do twice what any of these programs can combined.

    It has a steep learning curve, but so does programming; Vim is worth your time.

  23. 23

    Michael Brennan-White

    July 13, 2007 6:50 am

    Eclipse is awesome, cross platform and provides almost all of the functionality of Dreamweaver, and it is free.

    You can use some of the wonderful plugins like CFEclipse and Aptana to provide syntax highlighting but also much more including the best tool for debugging purposes, code folding.

  24. 24

    And none of them work with velocity…

  25. 25

    John Robo, the best COBOL formatter I could find is unlimited shareware; search for Cobol Beautifier.

  26. 26

    Is it any safe to blindly submit php code in those websites? Who knows it contains sensitive information (like database connections). Pay attention for these.

    @John: So you are one of the few people who program COBOL… nice. I think you can create your own style with Notepad++ (or change one of another language). But for auto formatting, I think it’s best to write something small yourself (in VB6 you’re quickly done).

  27. 27

    Thanks guys, very good tools although i use Dreamweaver in my work and also use it as an auto complete, i hate the auto generators. :S

  28. 28

    Thanks for the info, i was searching for something like this :)

    Extremely useful website

  29. 29

    I have coded in many environments, although the article is about code auto formatting software, I will just say that nothing compares to Visual Studio 2005 in real-time code formatting. It’s perfect.

  30. 30

    I’m tabified.

  31. 31

    Thanks for the tools review.
    I will check some of them when I can.

  32. 32

    Thanks guys. Great tools here. StartupByte.com is almost entirely built from the code/tools you guys have featured. Great work.

  33. 33

    You can also try Jush (http://jush.info/).

  34. 34

    Christopher Rees

    July 18, 2007 3:06 am

    I happen to like Scintilla, which is free and does great syntax highlighting, etc.


  35. 35

    Sois una panda gays con tanto color y tanta mierda.

    Viva el VI. Y digo el VI y no el VIM.

  36. 36

    Oh, I did not know you needed pretty-printers today. Don’t you know about Emacs?

    To be honest, what you can get from Emacs in this area are things like:
    – syntax highlighting
    – easy indentation (per line or for the whole file)
    – quick ways to make a html view of the code with syntax highlighting

    And you get that for a lot of programming languages, from C to XHTML, on Windows, Linux etc. That can be quite a timesave.

  37. 37

    Here’s one for XHTML. I noticed that all of the examples only validated to HTML 4.0


  38. 38

    I’m using http://www.jtidy.de to convert HTML to Wikipedia text and Java, PHP, C#, ABAP, XML, HTML and JavaScript snippets to Syntax highlighted code

  39. 39

    Anyone know of a Dreamweaver add-on that does this?

    I’m also looking for a dreamweaver extension that adds CSStidy functionality to dreamweaver… havent found anything yet…
    Someone should build this! (if only i knew how)

  40. 40

    in regards to my own comment above… I have started building a csstidy plugin for dreamweaver myself..
    when it is finished i’ll post the results to the csstidy sourceforge project

  41. 41

    There is also a free online sql formatter for SQL code. http://www.sqlinform.com

  42. 42

    Please give my HTML Formatter a look…a lot of people have found it very handy…Drag and drop folders or files, back ups, total reformats and beautifies the code.

  43. 43

    Wellington Oliveira

    March 27, 2008 9:51 am

    Polystyle do the right job!

    Dreamweaver integration with polystyle can be found here:


    sorry, wellington, but this domain is pending renewal or deletion (editor)

  44. 44

    I need a PHP beautifier or formatter for using in cmd or Putty for Linux .

  45. 45

    Jade Ohlhauser

    May 6, 2008 9:27 pm

    CSSTidy didn’t work for me so I wrote my own and you’re welcome to it if you like: http://jadeohlhauser.com/strip/

    (Windows only, sorry Tester, but you can have the source code if you like).

  46. 46

    Thomas Schweitzer

    June 22, 2008 11:43 pm

    On my way finding the right settings for the indenters I used, I got really annoyed trying out every setting by calling on command line again and again. Therefore I’ve developed a graphical user interface that can handle nearly any command line indenter if set up by a ini file. The app is called UniversalIndentGUI.

    Also if you’re looking for the indenter that suits your programming language best, the web site might give you useful info.

  47. 47

    I find it interesting to note how many people have confused Syntax Highlighting with Code Beautifying.

  48. 48

    i think coding, technique is easy, if we unterstand of, basic principle of structure….nice post

  49. 49

    Please note the official website of “SourceFormatX Source Code Formatter & Beautifier” has been changed to http://www.sourceformat.com, you had better modify the dead link.

  50. 50

    @editor #43: It would appear that domain is again active. (It appears to be a commercial source code formatter for Windows as far as I can tell.)


↑ Back to top