Modular invariance imposes rigid constrains on the partition functions of two-dimensional conformal field theories. Many fundamental results follow strictly from modular invariance, giving rise to the numerical modular bootstrap program. Here we report a way to assign to a particular family of quantum error correcting codes a family of code CFTs CFTs, which forms a subset of the space of Narain CFTs. This correspondence reduces modular invariance of the 2d CFT partition function to a few simple algebraic relations obeyed by a multivariate polynomial characterizing the corresponding code. Using this relation we construct many explicit examples of physically distinct isospectral theories, as well as many examples of nonholomorphic functions, which satisfy all basic properties of the 2d CFT partition function, yet are not associated with any known CFT.