Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

A simple, pure Ruby implementation of JSON code coloring

branch: master

Fetching latest commit…


Cannot retrieve the latest commit at this time

Octocat-spinner-32 app
Octocat-spinner-32 lib
Octocat-spinner-32 test
Octocat-spinner-32 .gitignore
Octocat-spinner-32 Gemfile
Octocat-spinner-32 LICENSE
Octocat-spinner-32 Rakefile
Octocat-spinner-32 Readme.markdown
Octocat-spinner-32 pizzazz.gemspec


Pizzazz is a simple pure Ruby implementation of code coloring, but just for JSON. Basically, if you have a ruby object and want to show it converted to JSON and add HTML around it so you can color it.

Cheddar uses this to show example output of it's API calls. Check it out.


Pizzazzifing an object is simple:

object = { name: 'Sam Soffes', website: '' }
#=> "{\n  <span class=\"string\">\"name\"</span>: <span class=\"string\">\"Sam Soffes\"</span>,\n  <span class=\"string\">\"website\"</span>: <span class=\"string\">\"\"</span>\n}"

You can optionally limit arrays as well:

Pizzazz.ify(all_of_the_things, limit: 1)

This will add an ellipses after the first element.


Spans are added around various elements. Here's the classes:

  • string
  • constant (true or false)
  • null
  • number

Everything else is left alone.

If you want it wrapped in <pre class="pizzazz"> (and call html_safe if possible), do the following:



If you're using the asset pipeline, you can simply require pizzazz to get my stylesheet. Be sure your <pre> has the pizzazz class. If you use ify_html it will automatically do this.


Add this line to your application's Gemfile:

gem 'pizzazz'

And then execute:

$ bundle

Or install it yourself as:

$ gem install pizzazz

Simple as that. Enjoy.

Something went wrong with that request. Please try again.