Superconductivity owes its properties to the phase of the electron pair condensate that breaks the $U(1)$ symmetry. In the most traditional ground state, the phase is uniform and rigid. The normal state can be unstable towards special inhomogeneous superconducting states: the Abrikosov vortex state, and the Fulde-Ferrell-Larkin-Ovchinnikov state. Here we show that the phase-uniform superconducting state can go into a fundamentally different and more ordered non-uniform ground state, that we denote as a phase crystal. The new state breaks translational invariance through formation of a spatially periodic modulation of the phase, manifested by unusual superflow patterns and circulating currents, that also break time-reversal symmetry. We list the general conditions needed for realization of phase crystals. Using microscopic theory we then derive an analytic expression for the superfluid density tensor for the case of a non-uniform environment in a semi-infinite superconductor. We demonstrate how the surface quasiparticle states enter the superfluid density and identify phase crystallization as the main player in several previous numerical observations in unconventional superconductors, and predict existence of a similar phenomenon in superconductor-ferromagnetic structures. This analytic approach provides a new unifying aspect for the exploration of boundary-induced quasiparticles and collective excitations in superconductors. More generally, we trace the origin of phase crystallization to non-local properties of the gradient energy, which implies existence of similar pattern-forming instabilities in many other contexts.