Rainbow.js - Simple syntax highlighting library written in JavaScript

Craig Campbell, an employee at Vimeo, has created a very easy to use, lightweight (~3k) code syntax highlighting library written in JavaScript. Out of the box, Rainbow supports syntax highlighting for the following languages:

  • JavaScript, HTML, CSS, PHP, Python, Ruby, C, Shell, Scheme, Lua, C#

Adding support for your own languages is very easy, however, and theming is done entirely with CSS. If you don’t want to sweat the details of theming, you can use one of their many built-in themes (like the very popular solarized theme).

Getting started is easy:

<pre><code data-language="ruby">def greeting(name)
  puts "Hello there #(name)"

Then include your CSS theme in the &lt;head&gt; and rainbow.js (as well as whichever language[s] you want) before the closing &lt;/body&gt;.

Checkout the demo or browse the source at GitHub. While you’re at it, feel free to fork the project and add support for your favorite language!

News Films

Our little film studio focuses on telling developer-centric stories that need to be seen.

Beyond Code: Season 3 / GopherCon 2015

0:00 / 0:00