91

What are the best online code beautifier and formatter out there? I'm not asking for highlighters. Any language will do.

Jon Clements
  • 138,671
  • 33
  • 247
  • 280
Tim Boland
  • 10,127
  • 8
  • 27
  • 25
  • 7
    viewed over 57k times... good thing you guys got on top of it and closed this – Daniel Feb 27 '13 at 22:08
  • Over 61k times now, so about 4k views in the last month. Yes, definitely not a constructive question. – Paul Apr 02 '13 at 13:50
  • Not sure why this topic was closed, but http://tohtml.com/javaProperties/ worked well for me. The styles and color are "inline" which makes it very simple to copy and paste into something else. – Andrew Bucklin May 19 '13 at 16:30

8 Answers8

108

CSS: code beautifier

HTML: HTML Tidy, CleanUp HTML or the general purpose Pretty Diff

Javascript: http://jsbeautifier.org/

PHP: http://beta.phpformatter.com/

SQL: http://dpriver.com/pp/sqlformat.htm

XML: http://chris.photobooks.com/xml/default.htm

Colour all: http://quickhighlighter.com/

Lemon Kazi
  • 3,308
  • 2
  • 37
  • 67
JamesM-SiteGen
  • 802
  • 2
  • 11
  • 26
25

For PHP, Java, C++, C, Perl, JavaScript, CSS you can try:

http://www.prettyprinter.de/index.php

QAZ
  • 4,870
  • 6
  • 36
  • 50
11

You can use Perl::Tidy for Perl.

brian d foy
  • 129,424
  • 31
  • 207
  • 592
9

JsonLint is good for validating and formatting JSON.

johnstok
  • 96,212
  • 12
  • 54
  • 76
5

What language?? There are different tools for almost every imaginable programming language, since they all have different syntactic rules and conventions.

Good ol' indent is a nice, customizable, command-line utility to format C and C++ programs.

Dan Lenski
  • 76,929
  • 13
  • 76
  • 124
  • 4
    Since the question asked for "online beautifier", do you know of any Web frontends to indent? – Anm Aug 10 '12 at 04:48
5

It depends of the language, and of the architecture you are using.

alt text alt text

For example, in a php platform, you can format almost language with GeSHi

As bluish comments, GeSHi is a generic syntax highlighter, with no beautification feature. It is more used on the server side, and combine it with a beautification tool can be tricky, as illustrated with this GeSHi drupal ticket.

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
2

I've used Quick Highlighter a lot. Works great for a huge list of languages.

AdamC
  • 16,087
  • 8
  • 51
  • 67
1

Use gist.github.com. There is a multi-language support(java, c, c++, c#, vb, haskell, ruby, javascript, lua, HTML, SQL, Tcl, Perl, JSON, groovy...)

Here is a sample "Generate LiquiBase changeLogs using Groovy"

rayyildiz
  • 338
  • 3
  • 7