Sperm chromatin is typically transformed by protamines into a compact and transcriptionally inactive state1,2. Sperm cells of flowering plants lack protamines, yet they have small, transcriptionally active nuclei with chromatin condensed through an unknown mechanism3,4. Here we show that a histone variant, H2B.8, mediates sperm chromatin and nuclear condensation in Arabidopsis thaliana. Loss of H2B.8 causes enlarged sperm nuclei with dispersed chromatin, whereas ectopic expression in somatic cells produces smaller nuclei with aggregated chromatin. This result demonstrates that H2B.8 is sufficient for chromatin condensation. H2B.8 aggregates transcriptionally inactive AT-rich chromatin into phase-separated condensates, which facilitates nuclear compaction without reducing transcription. Reciprocal crosses show that mutation of h2b.8 reduces male transmission, which suggests that H2B.8-mediated sperm compaction is important for fertility. Altogether, our results reveal a new mechanism of nuclear compaction through global aggregation of unexpressed chromatin. We propose that H2B.8 is an evolutionary innovation of flowering plants that achieves nuclear condensation compatible with active transcription.