Many bacteria and archaea possess a two-dimensional protein array, or S-layer, that covers the cell surface and plays crucial roles in cell physiology. Here, we report the crystal structure of SlpA, the main S-layer protein of the bacterial pathogen Clostridioides difficile, and use electron microscopy to study S-layer organisation and assembly. The SlpA crystal lattice mimics S-layer assembly in the cell, through tiling of triangular prisms above the cell wall, interlocked by distinct ridges facing the environment. Strikingly, the array is very compact, with pores of only ~10 Å in diameter, compared to other S-layers (30-100 Å). The surface-exposed flexible ridges are partially dispensable for overall structure and assembly, although a mutant lacking this region becomes susceptible to lysozyme, an important molecule in host defence. Thus, our work gives insights into S-layer organisation and provides a basis for development of C. difficile-specific therapeutics.