I'm searching a java library that formats/beautifies a given source code snippet. The library should support at least PHP and JavaScript source files.
The reason why i'm searching this is because the code that i generate with my Java application from a REST API description looks not to appealing. I am generating the source files with FreeMarker template engine and i don't want to implement all the formatting logic in the template files. It should be possible that way, but it makes the template files a lot harder to maintain.