Ars Magna: every anagram, exactly

Ars Magna = anagrams, rearranged

Ars Magna finds every anagram of whatever you type. Type Clint Eastwood, and it tells you there are exactly 85,882 ways to rearrange those letters into English words, lists every one of them, and puts Old West action on top.

Even the name is one: ars magna is Latin for “the great art,” and its letters spell anagrams.

A quick tour

Twenty-one seconds on the live site: a search for Clint Eastwood, a scroll through Discover, and dirty room built by hand from Dormitory.

Ars Magna isn’t just a list of anagrams, though. It’s built on six promises:

  • Every anagram, counted exactly. Not a sample, and not the first 500. The exact total comes first, before a single anagram is listed, even when it runs into the millions.
  • No AI in the search. The same text gives the same answers every time, and the engine is tested against a brute-force search that’s too simple to be wrong.
  • It runs on your device. The search engine is written in Rust and compiled to WebAssembly, so it runs in your browser. After one visit, it works with no network at all.
  • Open words. Every word comes from the English OpenList, pinned to one revision, in four dictionary sizes.
  • The good ones, explained. Discover collects 286 anagrams worth keeping, each with one sentence on why it fits.
  • Free. No ads, no accounts, and no cookies.

Try it

This is the real engine, the same code the site runs, loaded into this page. The first search downloads about 3 MB of dictionary. After that, every search happens on your device.

This demo needs JavaScript. You can search on the site instead.

The total arrives first because counting is much cheaper than listing; more on that below. Surprise me jumps to random positions in the full list without generating the anagrams before them, and Go to fetches any position you name. Try William Shakespeare, then go to anagram #10,000,000.

Why I built it

I’ve always loved word games, Wordle among them, and the ones about rearranging letters most of all. I even made my own: Amordle, a free Wordle–Hurdle hybrid with ranked multiplayer.

Ars Magna started with a joke. OpenAI named its GPT-5.6 models Sol, Terra, and Luna, and I noticed that Sol Terra Luna rearranges exactly into natural loser. Then OpenAI’s GPT-6 models came out as Astra, Sol, and Luna: a natural loss.

That made me wonder what else was hiding in everyday phrases, people’s names, and longer text: rearrangements that use every letter exactly once, spaces aside, and still say something funny or fitting. I started building Ars Magna on August 10, 2026, to find out.

The tools I found weren’t built for that. Anagram tools have been around for as long as the web has, but many of them list anagrams only until they reach a limit, and the limit is a setting: 500 results, or 10,000, or whatever a server can afford to send. A list that stops at 500 can’t tell you whether there were 600 or 6 million.

You could ask a chatbot instead. It’ll happily rearrange your name, and some of its answers will even use the right letters. Language models read text in word pieces, not single letters, and researchers have found that they still slip on anagrams, more so on long ones.

And the good anagrams are rare. Clint Eastwood has 85,882 of them at the site’s default settings, and Old West action is one. Most of the other 85,881 look like canto doles wit and dinos etc low at. Listing every anagram is half the job. The other half is finding the ones worth reading, and saying why they work.

So I built Ars Magna: a search that finds every anagram, counts them exactly, and keeps the good ones.

What came before

People have rearranged letters for fun for centuries, and computers have helped for decades. A few of the tools and communities that came first:

  • The Internet Anagram Server, by Anu Garg, has run on Wordsmith.org since 1994. It handles phrases in ten languages, and its advanced form shows 500, 1,000, 5,000, or 10,000 results, or all of them.
  • Anagram Genius, by William Tunstall-Pedoe, has been in development since 1988. It’s built to find good anagrams on its own, and its site keeps a hand-picked archive of about 25,000 of them.
  • Anagram Artist, by Mike Keith, takes the opposite approach. It’s a free Windows program that helps a person build an anagram by hand, suggesting words and keeping track of the letters left over.
  • an is a command-line anagram generator packaged for Debian. It finds anagrams of a phrase from any word list you give it.
  • The Anagrammy Awards are where people who make anagrams by hand compete, every month, for the best ones.

I’m not even the first to use the name. A Macintosh program called Ars Magna was generating every anagram of a phrase from its own dictionary in the 1980s.

Here’s what Ars Magna adds:

  • Exact counts, without listing. The engine counts a text’s anagrams without generating them. William Shakespeare has 18,113,773, and any one of them can be fetched by its position.
  • A search you can check. The same text gives the same answers every time, the tests compare the engine with a brute-force search, and the dictionary is pinned to one revision, so a result can be reproduced next year.
  • Curation with reasons. Discover doesn’t just rank anagrams. Every card says, in one sentence, why its anagram fits.
  • Both ways of working. Search for every anagram, or build one by hand with the letters counted for you.
  • Literal input. Digits and symbols count as themselves. An anagram of Blink-182 has to use the 1, the 8, and the 2.
  • Open data and tools. The collection and the vocabulary are open datasets, and the engine also ships as a command-line tool and an MCP server.

How the search works

An anagram on Ars Magna follows strict rules. Every letter of the text is used exactly once, nothing is added, nothing is dropped, and spaces can move anywhere. Capitals, punctuation, and accents don’t count, so Beyoncé has three e’s.

Under those rules, a text is just a bag of letters. Dormitory is one d, one i, one m, two o’s, two r’s, one t, and one y, and finding its anagrams means finding every way to split that bag into words.

The obvious method tries every word that fits, then every word that fits what’s left, and so on. It works, and it’s slow, because thousands of words fit at every step. So Ars Magna asks a sharper question first: which letter is scarcest? If one d is left, then exactly one word in every finished anagram contains that d, so only the words with a d need trying. Trying a few dozen words instead of thousands cuts the work by one to two orders of magnitude.

There’s a catch. A naive search finds dirty room and room dirty as two different answers. The textbook fix is to take words in a fixed order, and combined with the scarcest-letter trick, it’s wrong. It doesn’t produce wrong anagrams. It quietly loses right ones. The fix is to stay on one letter until every copy of it is used, and to keep words in order only within that stretch. Then every anagram is found exactly once.

The demo below runs both versions on a fifteen-word dictionary. Step through the search, then turn on the textbook shortcut and run it again.

This step-by-step demo needs JavaScript.

That’s why the engine’s most important test compares it with a brute-force search that’s far too slow for real use, but too simple to be wrong. The two have to find the same set of anagrams, not just the same number.

Counting without listing

Different paths through the search often leave the same letters behind, and the same leftover letters always have the same number of anagrams. So the engine remembers each count the first time it works one out. William Shakespeare has 18,113,773 anagrams at the site’s default settings, and the engine counts them in 10,899 steps, about 38 milliseconds on my laptop.

Because it knows how many anagrams sit under every branch, it can also walk straight to the ten millionth one without listing the 9,999,999 before it. That’s what Surprise me and Go to do in the demo at the top.

The words

Each word comes from the English OpenList, a free list of English words that I also built (its own post explains how), pinned to one revision so results can be reproduced. There are four nested dictionaries to choose from:

  • Common: 39,986 everyday words.
  • Standard (the default): 314,042 words, every attested word in the list.
  • Full: 378,879 words, the whole list at that revision.
  • Extended: 378,881 words, the whole list plus the site’s own additions, each with a meaning and a source.

Standard leaves out 64,837 entries that the source data generated by rule, like abacteremicer and nonlivabler, which would otherwise flood the results with words nobody uses. Full still has them. Opening a result says where each of its words came from, and 119,630 words have a definition from WordNet.

Nothing you type is replaced by something else, so a number is never read as its name. Blink-182 has no anagram made of words alone, since no word has a digit, but turning on the shorthand and blend classes finds terms that use the 1, the 8, and the 2. A few symbols can also stand in for a letter: Ke$ha gives $hake.

Discover

Discover is the part of the site I’d show a friend first. It holds 286 anagrams in three sections:

  • Greatest Hits (54): the best of them, picked by hand.
  • Interesting (80): anagrams that name the original, or have a clear, specific link to it.
  • A stretch (152): a looser link, arguable in a sentence.

Each card gives the text, its anagram, and one sentence on why the two fit.

This demo needs JavaScript. The cards are all on Discover.

Readers can vote for the cards they like. They can also put any anagram from a search forward for a place on the page, or submit one they built by hand.

New candidates can also come from the news. A nightly job takes the names and titles of the previous day’s most-viewed Wikipedia articles and runs them through the engine. Then a routine that uses a large language model judges how closely each anagram relates to its original and how it reads, and it reads the readers’ promotions the same way. Nothing goes up until I approve it.

The routine is paused for now, so I review promotions myself, regularly. I plan to turn it back on, and if promotions pile up, I’ll review them more often.

There are no accounts and no cookies. A vote is tied to a random id your browser makes, a Cloudflare Turnstile check keeps bots out, and pressing Vote again takes the vote back. The whole collection is an open dataset on Hugging Face, ars-magna-greatest-hits.

Build

Build is for making an anagram yourself. Type a text, and the letter tray lists its letters. Type your anagram, and the tray counts down: a letter used too often turns red, and one line says exactly what’s wrong.

This demo needs JavaScript. You can try Build on the site instead.

On the site, Build also checks every word against the dictionary you choose, and sets the two sides against each other in figures: letters, vowels, the rarest letters, word lengths, how common the words are, and a map with a line from each letter to where it went. Both boxes live in the page’s address, so a check is a link you can send.

How it’s built

Ars Magna is a static website with a search engine inside it. Everything a search needs runs in your browser, and the only thing a server does is store votes and promotions. That one decision shaped the rest: a search costs nothing to serve, what you search for stays on your device unless you promote an anagram, and the site keeps working offline.

The engine: Rust, compiled to WebAssembly

A hard search visits millions of states, so the engine is written in Rust, and it counts in 128-bit integers, which stay exact long after a JavaScript number would start rounding. The core library has no dependencies at all. The same code builds three ways: to WebAssembly for the site, with wasm-bindgen and wasm-pack (159 KB); as a native command-line tool; and behind the MCP server. One engine means the site, the command line, and the tests can’t disagree.

  • Letters as bytes. A word, or a bag of leftover letters, is 32 one-byte counts packed into four 64-bit integers. Checking whether a word fits what’s left, the step a hard search repeats tens of millions of times, then takes a few integer instructions, eight letters at a time, with no branches.
  • Classes, not words. Words with the same letters, like listen, silent, and tinsel, collapse into one class before the search starts, so 378,879 words become 350,489 classes. The search walks the classes and spells each result at the end, which is also why one row stands for every spelling of its letters.
  • A worker thread. The engine runs in a Web Worker, off the page’s main thread, so typing never stutters. A search can’t be interrupted from inside, so when you type before it finishes, the page throws that worker away and starts a fresh one.

The site: TypeScript, React, Vite, and Tailwind CSS

The interface is React 19 in TypeScript, built with Vite and styled with Tailwind CSS. The result list is virtualized with TanStack Virtual: only the rows on screen exist on the page, and rows come from the engine 250 at a time as you scroll, so a long list costs no more to draw than a short one. Searches, Build checks, and Discover cards all live in the page’s address, so any of them is a link.

The dictionary: a build step, not a server

A TypeScript build step fetches the English OpenList at its pinned revision, sorts it into the four tiers, and writes three compact binary files, named by a hash of their contents. A file that can never change can be cached forever, so after the first visit, the dictionary loads from your browser’s cache and a service worker serves the rest of the site offline. Compressed with brotli, the first visit downloads about 0.9 MB of dictionary instead of 3.2 MB. The definitions are split into 514 small files, fetched only for the words you open.

Hosting: Cloudflare Pages

Cloudflare Pages serves the site. Votes and promotions are the one part that needs a server: a few Pages Functions, in TypeScript, check each one with Turnstile and store it in a D1 database, which is SQLite. The build runs in GitHub Actions instead of Cloudflare’s build image, so the project controls its own Rust toolchain, and the dictionary files are committed, so publishing never depends on a download from anyone else.

Tests that check the right thing

  • The brute-force oracle from above, which compares every answer, not just the count.
  • A performance gate that counts the states a search visits instead of timing it. A timer fails on a slow computer; a count fails only when the search itself got worse.
  • Vitest for the TypeScript: the worker protocol, the exports, Build’s analysis, and the votes.

Use it

Open ars-magna.pages.dev. There’s nothing to install and no account to make, and after the first visit, the search works offline.

The code is on GitHub under the MIT license. To run the site yourself, you need Node 22 or later, pnpm, and a Rust toolchain with the wasm32-unknown-unknown target:

pnpm install
pnpm wasm:build
pnpm dev

The same engine runs from the command line:

cargo run --release -p anagram-cli -- solve "Clint Eastwood" --limit=10

It also ships as an MCP server, with tools to solve, count, fetch the nth anagram, and explain a word, so an AI assistant can look anagrams up instead of guessing at them. After pnpm wasm:build, node packages/mcp/bin/ars-magna-mcp.js starts it. The site’s vocabulary is an open dataset too: ars-magna-vocabulary.

What it doesn’t do yet

  • English only. Letters from other scripts are skipped, and the page says how many.
  • Some totals are too big to list. The United States of America has 116,576,660,306 anagrams. The count is exact, but nobody should try to list them, and exports stop at 100,000 rows.
  • The order is a judgment call. The default order tries to put readable anagrams first, and it doesn’t always manage. For Dormitory, it still lists dryroom it above dirty room.