A universal Krull–Lindenbaum theorem