The Library of Babel — Every Possible Page, Findable
Borges' infinite library, browseable. Every possible 3200-character page exists at a precise coordinate. Type any text and the search returns the exact address where that text appears. Real bidirectional bijection via BigInt math.
What this is
Borges' 1941 short story The Library of Babel describes a library containing every possible 410-page book of 80-column, 40-line pages using a 25-character alphabet. This demo implements that library as a website. Every coordinate (hexagon address + wall + shelf + book + page number) maps deterministically to a 3200-character page via pure BigInt math. Browse mode lets you visit any coordinate and read the page. Search mode lets you paste up to 3200 characters of your own text — the page returns the exact address where that text appears in the library. It always exists, by construction. The bijection has been verified to round-trip in both directions.
Why this is mind-blowing
The hardest part of this demo isn't the rendering — it's the math. The bidirectional bijection between 3200-character page text and its full library coordinate uses BigInt operations on numbers with 4,581 decimal digits. Round-trips complete in milliseconds. Borges wrote a philosophical essay about infinite libraries; the model wrote a working one in JavaScript from one paragraph of prompt.
Build Borges' Library of Babel as a browseable website. The library
contains every possible 410-page book of 3200 characters using a 27-
character alphabet. Each book has a unique coordinate. Use a
deterministic seeded PRNG so any coordinate always produces the same
content. Two modes: browse (pick a coordinate, read the book) and
search (paste any text, find the exact coordinate of the page that
contains it — it always exists, by construction). The math behind
the search is the audacious part. No backend.
Paste this into Claude, Cursor, or Copilot. Change one thing that matters to you.
What I learned shipping it
- The bijection trick: treat the 3200-character page itself as a base-27 number, and treat the (hex, wall, shelf, book, page) coordinate as the same number in a different decomposition. Both directions are pure BigInt math.
- 27^3200 is roughly 10^4583. JavaScript BigInt handles it in milliseconds — divmod loops are fast enough that no chunking or web workers are needed.
- The 'every possible text exists' result lands harder when you can paste your own sentence and immediately see its coordinate. Borges' essay becomes a tool, not a thought experiment.