Previous | ToC | Next Labs: Error Correction and Compression. Part 2. Math Alive

Lempel-Ziv Compressor

Below, you can try an automatic LZ compressor. In this version, we don't convert the text to binary first; the LZ algorithm implemented here uses all the ASCII characters, for the prefix numbers as well as the extra symbol at the end of each parsed string. For instance, the "empty" string position number is labeled by the character "space". (Even though the text eventually has to be stored in the computer as a binary chain, it is more efficient to implement LZ first for a character stream, before going over to the binary representation.)

Type text in the white window, and see what clicking the button Apply LZ Compression does to it! Instructions on how to "copy and paste" a large document can be found at the bottom of this page.

Lempel-Ziv Compressor

To compress something longer, like a large paper you wrote, or a book, you can use the standard cut and paste techniques. If your text is very large, the compressing could take a long time.

Detailed instructions for Windows or Mac:

  1. Open the document in Word (or whatever)
  2. Under the "Edit" menu, choose "Select All"
  3. Under the "Edit" menu, choose "Copy"
  4. Click inside the top window of Lempel-Ziv Compressor above
  5. Under the "Edit" menu (of the browser!), select "Paste" (you should see the text appear in the window)
  6. Hit the "Apply LZ Compression" button

If you cannot paste into the window (that is, the "Paste" option is not available under the "Edit" menu), try using the keyboard shortcut to paste. That is, look next to the "Paste" option in the "Edit" menu and note the corresponding character sequence for "Paste". Often, it is Control-v (hold the Control or Ctrl key and press v) or Alt-v (hold the Alt key and press v). Click in the text window and try the keyboard shortcut. If this also does not work - try a different browser or browser version, or send email (

Previous | ToC | Next Last Modified: August 2008