A developer has created a custom encoding scheme capable of representing the average national flag in just 76 bits, or approximately 9 characters in a Base94 format. By treating flags as a series of layered geometric components—such as stripes, stars, and crescents—the system allows for highly compressed data that can be reconstructed into recognizable SVG graphics.

This visual demonstrates the final output of the decoding and rendering process.
The Geometric Layer Model
The encoding treats a flag as a composite of distinct visual elements rather than a static image. It defines a protocol where flags are built from layers, similar to how software like Photoshop handles objects. For example, the United States flag is constructed by first defining a stripe layer, followed by a blue rectangle region, and finally a star shape layer.
Chart drawn by HN Digest from figures reported by vantezzen.io; values are shown as written in the source.
Common elements are categorized into specific types: stripes (horizontal, vertical, or angled), shapes (stars, crescents, circles), and regions (rectangles or bands). Specialized components, such as the Union Jack, are treated as 'built-in' shapes to simplify the construction of flags like those of Australia or New Zealand.
“The average flag can be represented in 76 bits, with a median of 55 bits.”
— Compressing a flag to 11 bits · vantezzen
Huffman Coding and Bit Packing
To achieve high compression, the system employs Huffman trees to assign binary codes based on the frequency of flag features. Because 45% of national flags share a 2:3 aspect ratio, the system assigns this common trait a single bit (0). Similarly, the most frequent colors—red, white, and blue—are given short bit-sequences within a defined color palette.

This image illustrates the process of turning geometric flag components into a bit-packed format.
The format handles the 'long tail' of unique flags by using a 'Custom' leaf in the Huffman tree. If a flag has a rare attribute, such as El Salvador's 189:335 aspect ratio, the system switches to a fixed-length free value option. This allows the encoding to remain compact for common flags while still supporting outliers.
Trade-offs and Limitations
The primary trade-off of this geometric approach is the loss of heraldic precision. The system intentionally ignores exact color shades and intricate details in favor of 'recognizable' accuracy. While this works for simple designs like Indonesia's, it struggles with flags containing complex coats of arms, seals, or animal glyphs.
Currently, 67 flags remain unencodable because they contain elements the geometric model cannot express, such as the Y-shapes of Afghanistan or the intricate emblems of countries like Spain and Mexico. While a simple 8-bit lookup table could represent these flags more accurately, it would lack the generative flexibility and bit-saving potential of the Huffman-based bit-packing method.
What Hacker News readers are saying
- Alternative: One commenter suggested that a simple 8-bit lookup table would be superior to the 11-bit encoding because it could handle complex heraldry and nearly identical flags more effectively. comment ↗
- Skeptical: A commenter expressed skepticism regarding the success of the scheme, noting that it failed to encode approximately 35% of the world's population, including several countries with simple flags. comment ↗
- Technical note: Another user proposed a different technical approach involving color quantization and solving a minimum test set problem to find the smallest subset of pixel locations that distinguish every flag. comment ↗
- Skeptical: One reader questioned the effectiveness of the encoding, arguing that since the goal is to draw the flag rather than store a list of unique items, an 8-bit ID system would suffice. comment ↗
Summarized opinions from the Hacker News thread, not verified facts. Read the full discussion ↗