Modular invariance imposes rigid constraints on the partition functions of two-dimensional conformal field theories (CFTs). Many fundamental results follow strictly from modular invariance and unitarity, giving rise to the numerical modular bootstrap program. Here we report on a way to relate a particular family of quantum error correcting codes to a family of "code 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 correspondence, we construct many explicit examples of physically distinct isospectral theories, as well as many examples of nonholomorphic functions, which satisfy all the basic properties of a 2D CFT partition function, yet are not associated with any known CFT.