A C Source to Colorized HTML Converter
for MSVC (6.0)



CToHTML is a tool that converts from raw C source files to HTML files showing the source colorized in the (default) manner of MSVC.  The purpose of the tool is to allow quick conversion from classroom examples to web archives that look the same as they do in the development environment.

All CToHTML does is recognize keywords and comments, putting them in colors specified by a style sheet embedded in the output HTML.  The comments are C format (/*....*/ and //...), and that recognition is built into the code and cannot be changed.  The keywords are simply matches against tokens in an editable file, possibly making it useful for C++ and Java files, and maybe even something further afield.

Download, Install, and Uninstall

CToHTML is available only for Windows on Intel processors.  It should run in anything as modern as Windows 95, but it was developed and tested on Windows 2000.

CToHTML is distributed as a zip file.  Just download, unzip, and run setup.  Uninstall is through the normal Start / Settings / Add/Remove Programs.


The installation process will leave a shortcut on your desktop, "CToHTML Drop Box".  Simply drag-and-drop one or a group of  .c files onto this icon. Files with the same names, but with ".html" appended, will appear in the folder from which the .c files were dragged.

Double-clicking on the desktop icon brings up a customization dialog, discussed next.


Some attempt has been made to allow customization, including possibly application to files other than C source.  Much of what is does is table driven, and the tables are accessible.  Running CToHTML with no parameters, such as by double-clicking on its shortcut, brings up a dialog that allows you to set various execution parameters:

Keyword Filename

The name of a file of tokens to be recognized as keywords.  Each such match is given a unique style in the output HTML.  (By default, such words are painted in blue.)

For all files, CToHTML looks first in the directory from which the source file came, and if one is not located there, then looks in the directory in which the executable lives.  Specifying an absolute pathname in this box obviously defeats this.  The file browser button that is available insert absolute pathnames by default.

HTML Header Filename

The contents of this file are prepended to the (translated) source file contents to form the HTML output.  This file contains the style sheet specifications, so that editing it allows you to change colors, fonts, or whatever.  It also contains a rather lengthy comment about how the viewer of your HTML page can capture just the C source from it (without the HTML tags) in case they want to try compiling your posted examples.

HTML End Filename

The contents of this file are written to the output HTML file after the entire (translated) source file.

Token Terminators

Each character in this string terminates tokens to the parser.  You do not need all such characters from C for CToHTML to do everything it's capable of doing, since it doesn't do anything special for most tokens.  Only characters that might terminate a keyword need be here.  (Whitespace is not required, as that is built into the parser code.)

Comment Delimiters

Individual comment delimiters are pairs of strings, the first specifying a string that starts a comment and the second a string that terminates it.  The two strings are separated by a hyphen ('-').  Consecutive delimiter pairs are separated with a semi-colon (';').  The character sequence "\n" in a comment termination delimiter means "up to the end of the line".  As an example, here is the default delimiter string


Source File Tab Stops

The tab stops you used in creating the source file to be translated.  In MSVC, the default is 4, but this allows you to change it to whatever you want.


CToHTML can write a brief log of everything it tries to do.  This might help diagnose problems if it doesn't work for you.  The log file is written to the directory in which the executable lives.  By default, logging is off.

Help Button

Attempts to launch "C:\Program Files\Internet Explorer\iexplore.exe" to display a local copy of this file.


Send me mail, once per bug/request.