Sven Lennartz

About The Author

Sven Lennartz 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.

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 facts are particularly important if the code is being developed by a group of developers: in this context a common scheme for source code...

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

  1. Quick Highlighter
  2. 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.

    Screenshot

  3. PrettyPrinter
  4. 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.

    Screenshot

  5. PHP Code Beautifier
  6. 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.

  7. Ruby Script Beautifier
  8. 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.

  9. Tabifier
  10. 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.

    Screenshot

  11. CSS Beautifier
  12. This tool offers a variety of options, among them - Alphabetizing Feature and De-Capitalization Feature.

    Screenshot

  13. Highlight.js
  14. 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 Prettifier.

    Screenshot Screenshot

  15. PHP Formatter
  16. 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.

    Screenshot

  17. PHP_Beautifier
  18. A tool to beautify PHP 4 and PHP 5 source code - to run on your own server. Requires PHP 5.

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

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

    Commercial Solutions

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

    Screenshot

  25. Polystyle
  26. 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.


More Articles on

30 Scripts For Galleries, Slideshows and Lightboxes

by Sven Lennartz

Family photos, vacation snapshots or creative artistic works: whatever images you have to present, you can present them in a variety of ways. On a big screen, in slide shows or in a thumbnails gallery. However, to convey the message of presented data effectively, it's important to offer it in an attractive and intuitive way. Furthermore, the presentation itself can make images more valuable and...

Read more

70 Expert Ideas For Better CSS Coding

by Vitaly Friedman

CSS isn't always easy to deal with. Depending on your skills and your experience, CSS coding can sometimes become a nightmare, particularly if you aren't sure which selectors are actually being applied to document elements. An easy way to minimize the complexity of the code is as useful as not-so-well-known CSS attributes and properties you can use to create a semantically correct markup. ...

Read more

Microformats: What They Are and How To Use Them

by Vitaly Friedman

Web 2.0 has its positive and its negative sides. Apart from tremendous technological improvements, provided by Ajax, semantically organized content and the growing popularity of RSS-Feeds, the term "Web 2.0" still hadn't managed to assert itself as the renewed Web rather than a new revolutionary technology as it is mistakenly being called. Consequence: many renewed techniques, which somehow...

Read more