Source code viewing as a service
Ruby CSS JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Source Viewer

Source Viewer is source code viewing as a service, a simple web service that allows you to see the source code of a web page (or any other file that can be accessed through an URL).

source viewer screenshot


The source code of web pages can already be seen by using the contextual menu "view page source" on your web browsers, but this is not enough.

I wanted the ability to jump directly to a line by using an anchor, and also to colorize the syntax (not all web browsers do this automatically).

Sometimes, you can't even use the contextual menu as it has been disabled on the web page that you want to inspect.

But the main reason was to have a way to link to this source view directly, instead of using a contextual menu.


This is a Sinatra app, ready to be deployed into production on your server. This is extremely easy to do on Heroku, you just need to push it and you're ready to go.

Using it

The app has just one entry point, that accepts a single parameter for the URL to be shown, here's an example:

This will fetch the URL and show it, that's all.

You can also jump to a line by using an anchor on the URL, like this:

Following redirections

This app uses the OpenUriRedirections gem, that patches Ruby's OpenURI to allow redirections from HTTP to HTTPS and vice versa.

Specifying an User Agent

If you want to specify a custom User Agent to be used when fetching the page, you can use the user_agent param, like this:

Choosing a theme

You can use a different Highlight.js CSS theme using the theme param, like this:

Getting development env ready

Install gems for development

bundle install

Launch app in development:

We use the rerun gem so that it detects changes in the filesystem and reloads the app automatically.

rerun 'ruby app.rb'

The local server will be accessible at http://localhost:4567


This is free open source software uses the MIT license.