Fork me on GitHub


The LessCSS Compiler is a Java library which compiles Less source files to the CSS code.

From Less website:
Less is a CSS pre-processor, meaning that it extends the CSS language, adding features that allow variables, mixins, functions and many other techniques that allow you to make CSS that is more maintainable, themable and extendable.


The compiler is compatible with version 1.7.5. The library is based on the official Less JavaScript compiler adapted to the Rhino engine.


  • cannot fetch sources from Internet, e.g. @import (less) ""


The compiler to run requires:

  • Java 5.0 or higher
  • Third-Party Dependencies (see list)


You can download the library from this page or using various dependency management tools.


The idea for the LessCompilerImpl class was based on the lesscss-java library by Marcel Overdijk.


How to compile a source file:

// create compiler & source file
LessCompiler compiler = new LessCompilerImpl();
File source = new File("/less/file.less");

// compile file with default options
String cssCode = compiler.compile(source); 

// set custom option: minify CSS code
CompilerOptions options = new CompilerOptionsBuilder().setMinified(true).create();
String cssMinifiedCode = compiler.compile(source, options);