The dorsal horn of the spinal cord is critical to processing distinct modalities of noxious and innocuous sensation, but little is known of the neuronal subtypes involved, hampering efforts to deduce principles governing somatic sensation. Here we used single-cell RNA sequencing to classify sensory neurons in the mouse dorsal horn. We identified 15 inhibitory and 15 excitatory molecular subtypes of neurons, equaling the complexity in cerebral cortex. Validating our classification scheme in vivo and matching cell types to anatomy of the dorsal horn by spatial transcriptomics reveals laminar enrichment for each of the cell types. Neuron types, when combined, define a multilayered organization with like neurons layered together. Employing our scheme, we find that heat and cold stimuli activate discrete sets of both excitatory and inhibitory neuron types. This work provides a systematic and comprehensive molecular classification of spinal cord sensory neurons, enabling functional interrogation of sensory processing.