ASCII Art to GIF Converter
Convert multi-frame ASCII art into animated GIF files. Real GIF89a encoding with LZW compression, custom colors, speed control, and live preview.
About
ASCII art animation predates modern graphics by decades. Artists create frame-by-frame motion using characters from the 95-printable subset of US-ASCII (codes 32 - 126). Converting these text frames into a distributable GIF requires binary-level encoding: a GIF89a header, a Global Color Table mapping N colors to 3-byte RGB triplets, Graphics Control Extensions specifying per-frame delay in centiseconds, and LZW-compressed pixel data for each Image Descriptor block. Errors in the LZW code table or missing trailer bytes produce corrupt files that silently fail in browsers. This tool performs real GIF89a encoding entirely in your browser with no server round-trip.
The encoder maps each character cell to a pixel block of configurable size, applies your chosen foreground and background colors, and compresses frames using variable-length LZW with a minimum code size of 2 bits. Frame delay d is specified in hundredths of a second (centiseconds), so a value of 20 yields 50 fps apparent playback. Note: most renderers clamp minimum delay to 20 ms regardless of specification. The tool approximates smooth animation within these browser-imposed constraints.
Formulas
Each ASCII frame is rendered onto a canvas where every character occupies a cell of w × h pixels determined by the monospace font metrics. The total image dimensions are computed as:
where cols is the maximum line length across all frames and rows is the maximum line count. Frame delay in the GIF spec uses centiseconds:
LZW compression begins with a code table of size 2minCodeSize + 2 (including Clear and EOI codes). The compressor emits variable-length codes starting at minCodeSize + 1 bits, increasing width when the table index reaches 2currentBits. The table resets via a Clear Code when it reaches 4096 entries (the 12-bit maximum).
where W = image width in pixels, H = image height in pixels, cols = character columns, rows = character rows, w = cell width in pixels, h = cell height in pixels, dcs = frame delay in centiseconds, fps = frames per second, minCodeSize = LZW minimum code size (typically 2 for small palettes), codeWidth = current LZW output bit width.
Reference Data
| GIF Block | Offset | Size (bytes) | Purpose |
|---|---|---|---|
| Header | 0 | 6 | Signature + Version (GIF89a) |
| Logical Screen Descriptor | 6 | 7 | Canvas width, height, color table flags |
| Global Color Table | 13 | 3 × 2N | RGB palette entries |
| Application Extension | Variable | 19 | NETSCAPE2.0 looping block |
| Graphics Control Ext. | Per frame | 8 | Delay time, disposal method, transparency |
| Image Descriptor | Per frame | 10 | Frame position, dimensions, local table flag |
| Image Data | Per frame | Variable | LZW min code size + sub-blocks |
| Trailer | Last | 1 | Byte 0x3B signals end of file |
| LZW Min Code Size | - | 1 | Typically 2 - 8 bits |
| LZW Clear Code | - | - | 2minCodeSize |
| LZW EOI Code | - | - | Clear Code + 1 |
| Max Code Size | - | - | 12 bits (4096 entries max) |
| Sub-block Max | - | 255 | Max bytes per data sub-block |
| Disposal Method 0 | - | - | No disposal specified |
| Disposal Method 1 | - | - | Do not dispose (overlay) |
| Disposal Method 2 | - | - | Restore to background color |
| Disposal Method 3 | - | - | Restore to previous frame |
| Common Delay: 10 fps | - | - | 10 centiseconds per frame |
| Common Delay: 5 fps | - | - | 20 centiseconds per frame |
| Common Delay: 2 fps | - | - | 50 centiseconds per frame |
| Max GIF Dimensions | - | - | 65535 × 65535 px |