We show how to construct a large class of quantum error correcting codes, known as CSS codes, from highly entangled cluster states. This becomes a primitive in a protocol that foliates a series of such cluster states into a much larger cluster state, implementing foliated quantum error correction. We exemplify this construction with several familiar quantum error correction codes, and propose a generic method for decoding foliated codes. We numerically evaluate the error-correction performance of a family of finite-rate CSS codes known as turbo codes, finding that it performs well over moderate depth foliations. Foliated codes have applications for quantum repeaters and fault-tolerant measurement-based quantum computation.