Hacker News

Can you build a recognizable World Map in under 500 bytes?

Comments

A little over 10 years ago, I entered a JS1k competition and built a small jsfiddle clone in under 1k. A few years later, I joined the competition again to see if it was possible to build a World Map in under 1k.

My approach was to render the world as ASCII inside a <pre> tag and use tiny characters for land and water. It worked, but lately I wanted to see if we can go even smaller in size, perhaps with the help of GenAI.

Trying Codex

I have been doing a lot with Claude Code so for this I wanted to try Codex, and I was surprised that AI did not perform very well. Codex considered a variety of approaches, starting with SVG which failed because 500 bytes seems not enough to draw anything recognizable.

A real-looking world map is mostly coastline detail, and SVG/canvas paths have to pay for every coordinate. Once the shapes were simplified enough to be small, they stopped looking like the world.

Eventually, Codex landed back on ASCII format but it did not recommend further improvements like removing anything that did not help recognition.

Optimizing the ASCII Approach

I suggested that:

  • Water dots could be removed
  • The empty left margin was cropped
  • The map was reduced to land-only * characters inside a tighter bounding box

We tested removing the filled interiors and keeping only continent outlines, but that actually compressed worse. Filled land creates long predictable runs of repeated characters, and compression loves repeated runs more than sparse outlines with lots of little gaps.

The Compression Breakthrough

The final compression step used deflate-raw on the land-only cropped map. The visible map text was still 8,523 bytes uncompressed, but the compressed map data dropped to 445 bytes.

I think that was the highlight - not drawing a less detailed map but choosing a representation that compression can exploit. The HTML is larger (still under 1k) because it needs base64 data plus browser decompression code, but the map itself is under 500 bytes.

You can check it out here and this is the repo.

The Challenge

Now, can someone beat this with a different approach (not just removing a few characters) or generate a 1k version that is more realistic?

Comments

No comments yet. Start the discussion.