DOSAYGO Studio

Base437: Retro Binary Visualization in HTML

By Cris, March 15, 2025

Displaying binary data in HTML is often obscured by encoding like Base64, hiding its raw form. I tackled this with Base437, a JavaScript library that maps binary data to IBM Code Page 437 characters, using data URLs for direct rendering. In the web’s retro tech museum, Base437 is a glowing CRT display, showcasing binary in the pixelated charm of 1980s DOS.

Base437 maps each byte to a Code Page 437 Unicode character, with the tr API allowing custom mappings for contexts like HTML attributes, ensuring compatibility.

function encodeBase437(binaryData) {
  const codePage437Map = new Map([
    [0x00, '\u2400'], // NUL symbol
    [0x01, '\u263A'], // Smiley face
    // ... (mapping for all 256 Code Page 437 characters)
    [0xFF, '\u25A0']  // Block
  ]);
  let result = '';
  for (let byte of new Uint8Array(binaryData)) {
    result += codePage437Map.get(byte) || '\uFFFD'; // Fallback to replacement char if unmapped
  }
  return `data:text/plain;charset=utf-8,${encodeURIComponent(result)}`;
}

This code maps binary bytes to Code Page 437 characters, rendering them directly in HTML. Base437’s nostalgic utility makes binary data visually accessible.

Base437 interface: a retro DOS terminal with glowing Code Page 437 characters, evoking 1980s tech

Building Base437 was like restoring a vintage computer, each glyph a piece of history. At DOSAYGO, we value blending nostalgia with utility, creating tools that bridge past and present. Base437 is a window to the web’s origins, illuminating binary in a pixelated glow.