Alloy is a web API for compiling CSS using preprocessors.

Bookmarklets

Tired of having to write plain old CSS in the "Custom CSS" field on websites? These bookmarklets will allow you to compile any textarea filled with a preprocessor language into CSS. Just click the bookmarklet then click the textarea. Drag your favorite to the bookmark toolbar!

API Reference

To use the Alloy API, you will make a simple POST request to http://alloy.divshot.com/compile. The request can either be of type applicaton/json or application/x-www-form-encoded and must include a source parameter with the uncompiled code and a type parameter. The type parameter can be any one of sass, scss, less, and stylus.

You can additionally pass a compress parameter if you would like the resulting CSS to be minified.

Example

POST http://alloy.divshot.com/compile
Content-Type: application/json

{
  "type":"sass",
  "source":"@import \"compass\"\n\n.btn\n  @mixin border-radius(15px)\n  background-color: blue",
  "compress":true
}

Calling Alloy From the Browser

Alloy supports Cross-Origin Resource Sharing (CORS) so you can safely make AJAX requests directly to the Alloy endpoint. Here's a jQuery example:

$.ajax({
  url: "http://alloy.divshot.com/compile",
  type: "POST",
  dataType: "text",
  data: {
    compress: true,
    type: "sass",
    source: "body\n  color: blue"
  },
  success: function(css) {
    $("#some-element").text(css);
  }
});