viewhack

Read a Windows help file (.chm) on a Mac, phone or Linux

You have a .chm, a program's manual, an old piece of software's help or an e-book packed as Compiled HTML Help, and the device in front of you is a Mac, a Chromebook, a Linux machine or a phone, none of which opens it. Drop it here: the title, the contents tree, the index, a search over every page, and each page with its pictures and working links.

The file is read on your device. It is not uploaded, and no script in it is run.

What it shows

What is inside a .chm file

A .chm is a small file system packed into one file, the format Microsoft introduced with HTML Help in 1997. It starts with a 96-byte header: the letters ITSF, the format version (3), a timestamp, the language ID (LCID) and where the directory and the content begin. The directory, after an ITSP header, is a run of chunks, usually 4,096 bytes each. PMGL chunks list every file with its name, the section it is in, and its offset and length, each number written as an ENCINT (7 bits per byte, the top bit saying another byte follows). PMGI chunks index the listing, so a reader can find one name without scanning every chunk.

Files live in one of two sections. Section 0 is stored as is and holds the container's own bookkeeping. Section 1, named MSCompressed, is every page, picture and stylesheet joined end to end and compressed with LZX, the method from Microsoft's .cab files: Huffman-coded bytes and back-references into a window of 32 KB to 2 MB (64 KB in most help files). So that a reader can open one page without unpacking the whole file, the compressor starts afresh at fixed points, usually every 64 KB of output, and a reset table records where each point lies in the compressed data. This page unpacks only the 64 KB pieces a page needs, so one page of a 30 MB manual opens quickly; a full-text search reads them all.

A record called #SYSTEM names the title, the contents file (.hhc), the index file (.hhk) and the default page. The .hhc and .hhk are ordinary HTML lists of <OBJECT type="text/sitemap"> entries. A worked example: the PuTTY 0.83 manual, putty.chm, is 367 KB and holds 586 files, 567 of them pages. Its compressed section unpacks from 337 KB to 2.6 MB in 41 pieces of 64 KB, and its index has 997 keywords.

Why a .chm often will not open, even on Windows

Windows blocks the pages of a .chm that came from the internet: the help window opens with its contents tree, but every page says “This program cannot display the webpage” or “Navigation to the webpage was canceled”. The fix there is to right-click the file, choose Properties and tick Unblock (or keep the file on a local drive, not a network share). macOS, iOS, Android and ChromeOS have no .chm viewer at all, and Linux needs a separate program such as xCHM or KchmViewer. This page uses none of them, so neither problem applies.

That blocking exists for a reason: Windows' help viewer runs a .chm's scripts and ActiveX controls with the rights of a local program, and .chm files have long been used to deliver malware. Here every script, event handler, javascript: link and ActiveX object is removed before a page is shown, and the frame it is shown in is not allowed to run scripts in any case.

Files it opens

.chm
Compiled HTML Help, written by Microsoft's HTML Help Workshop and by tools such as Halibut, Help & Manual, RoboHelp, Sphinx and Doxygen (through hhc.exe). Program manuals, SDK and old MSDN references, the PHP and Python manuals of their day, and e-books.
.chi
The index companion that large help collections split off. It is the same container and opens, but it holds index data rather than pages.
Not opened
WinHelp files (.hlp) from Windows 3.1 to XP, a different format; Microsoft Reader e-books (.lit) and Help 2 files (.hxs), which start with ITOLITLS and are named as such.

What this cannot do