The spinal cord is the initial stage that integrates temperature information from peripheral inputs. Here we used molecular genetics and in vivo calcium imaging to investigate the coding of cutaneous temperature in the spinal cord in mice. We found that heating or cooling the skin evoked robust calcium responses in spinal neurons, and their activation threshold temperatures distributed smoothly over the entire range of stimulation temperatures. Once activated, heat-responding neurons encoded the absolute skin temperature without adaptation and received major inputs from transient receptor potential (TRP) channel V1 (TRPV1)-positive dorsal root ganglion (DRG) neurons. By contrast, cold-responding neurons rapidly adapted to ambient temperature and selectively encoded temperature changes. These neurons received TRP channel M8 (TRPM8)-positive DRG inputs as well as novel TRPV1(+) DRG inputs that were selectively activated by intense cooling. Our results provide a comprehensive examination of the temperature representation in the spinal cord and reveal fundamental differences in the coding of heat and cold.