| CARVIEW |
Select Language
HTTP/2 302
server: nginx
date: Sun, 18 Jan 2026 01:34:22 GMT
content-type: text/plain; charset=utf-8
content-length: 0
x-archive-redirect-reason: found capture at 20100206034128
location: https://web.archive.org/web/20100206034128/https://coderay.rubychan.de/
server-timing: captures_list;dur=0.407386, exclusion.robots;dur=0.028938, exclusion.robots.policy;dur=0.021055, esindex;dur=0.006548, cdx.remote;dur=8.998182, LoadShardBlock;dur=220.242085, PetaboxLoader3.datanode;dur=76.248976, PetaboxLoader3.resolve;dur=69.720647
x-app-server: wwwb-app246-dc8
x-ts: 302
x-tr: 259
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=0
set-cookie: wb-p-SERVER=wwwb-app246; path=/
x-location: All
x-as: 14061
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
HTTP/2 200
server: nginx
date: Sun, 18 Jan 2026 01:34:23 GMT
content-type: text/html; charset=utf-8
x-archive-orig-date: Sat, 06 Feb 2010 03:41:39 GMT
x-archive-orig-server: Mongrel 1.1.5
x-archive-orig-status: 200 OK
x-archive-orig-cache-control: no-cache
x-archive-orig-content-length: 12859
x-archive-orig-via: 1.0 coderay.rubychan.de
x-archive-orig-vary: Accept-Encoding
x-archive-orig-connection: close
x-archive-guessed-content-type: text/html
x-archive-guessed-charset: utf-8
memento-datetime: Sat, 06 Feb 2010 03:41:28 GMT
link: ; rel="original", ; rel="timemap"; type="application/link-format", ; rel="timegate"
content-security-policy: default-src 'self' 'unsafe-eval' 'unsafe-inline' data: blob: archive.org web.archive.org web-static.archive.org wayback-api.archive.org athena.archive.org analytics.archive.org pragma.archivelab.org wwwb-events.archive.org
x-archive-src: TLA-20100206031749-01020-01029-ia360908-20100207034159-00000-c/TLA-20100206034025-00976-ia360915.us.archive.org.warc.gz
server-timing: captures_list;dur=0.389261, exclusion.robots;dur=0.012657, exclusion.robots.policy;dur=0.004822, esindex;dur=0.008408, cdx.remote;dur=172.097002, LoadShardBlock;dur=205.889158, PetaboxLoader3.resolve;dur=103.441912, PetaboxLoader3.datanode;dur=101.146564, load_resource;dur=121.345464
x-app-server: wwwb-app246-dc8
x-ts: 200
x-tr: 542
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=0
x-location: All
x-as: 14061
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
content-encoding: gzip
CodeRay

![]() | Try it!Paste your code | DownloadGem | Subversion | Documentation |

CodeRay is a fast syntax highlighting library written completely in Ruby.
It features fast HTML generation and a really advanced Ruby scanner.
Features
input languages
- C
- C++*
- CSS
- Delphi
- diff
- Groovy* (beta)
- HTML
- Java
- JavaScript
- JSON
- Nitro-XHTML
- PHP*
- Python*
- RHTML (ERB+HTML)
- Ruby
- Scheme (beta)
- SQL*
- XML
- YAML
output formats
- HTML (span/div/page)
- JSON*
- XML
- YAML
- Terminal* (beta)
tools
- comment filter*
- LoC counter* (beta)
- token statistiks
* = new in 0.9.1
basic features
- fast (some 100 KB/s)!
- safe (doesn't choke on bad code)
- plugin system for
- scanners
- encoders
- styles
- extensive test suite
- reusable representation of tokens
- reusable scanners and encoders
- token streaming (to save memory)
- scanner inheritance and inclusion
More features are planned for 1.0 and 1.1.
Usage & Live Demo
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
require 'rubygems' require 'coderay' # output as HTML div (using inline CSS styles) puts CodeRay.scan('puts "Hello, world!"', :ruby).div # ...with line numbers puts CodeRay.scan("5.times do\n puts 'Hello, world!'\nend", :ruby).div(:line_numbers => :table) # output as standalone HTML page (using CSS classes) puts CodeRay.scan('puts "Hello, world!"', :ruby).page # keep scanned tokens for later use tokens = CodeRay.scan('{ "just": "an", "example": 42 }', :json) # produce a token statistic puts tokens.statistic # count the tokens tokens.count # => 26 # produce a HTML div, but with CSS classes puts tokens.div(:css => :class) # highlight a file (HTML div); guess the file type base on the extension # puts CodeRay.highlight_file('foo.erb.html') # get a new scanner for Python python_scanner = CodeRay.scanner :python # get a new encoder for terminal terminal_encoder = CodeRay.encoder :term # scanning into tokens tokens = python_scanner.tokenize 'import this; # The Zen of Python' # format the tokens puts terminal_encoder.encode_tokens(tokens) # re-using scanner and encoder ruby_highlighter = CodeRay::Duo[:ruby, :div] puts ruby_highlighter.encode('puts "Hello, world!"') |
More documentation is also available.

