The crystal structures of N,N-dimethylthioformamide and N,N-dimethylformamide were determined at 90 ± 2 K from single crystal X-ray diffraction data. Both compounds comprise planar molecules, a consequence of the π-electron delocalization over the N–C–S and N–C–O entities, respectively. In N,N-dimethylthioformamide, almost linear, 175.4(7)°, C–H
⋯
S cooperative hydrogen bonding between the thioformyl groups connects the molecules in helix-shaped chains with an intermolecular C
⋯
S distance of 378.10(7) pm. The two crystallographically independent molecules in N,N-dimethylformamide form four-membered centrosymmetric rings held together by C–H
⋯
O intermolecular interactions, two via the formyl protons, C
⋯
O 329.41(9) pm, and two involving methyl protons, C
⋯
O 341.41(9) pm. The structures of both liquids were studied at room temperature by large angle X-ray scattering in transmission mode and for N,N-dimethylthioformamide also in reflection geometry. The structure of liquid N,N-dimethylformamide can, despite the stronger hydrogen bond acceptor properties of the oxygen atom, be described without hydrogen bonding. This apparent anomaly with more significant effect of hydrogen bonding in both crystal and liquid forms of N,N-dimethylthioformamide than N,N-dimethylformamide is discussed using results from theoretical calculations on single molecules. Mulliken population analyses indicate a lower positive charge and thus weaker hydrogen-bond donor properties of the formyl than of the thioformyl hydrogen atom. Raman and infrared spectra of the solids and the liquids are used for discussions of the hydrogen bonding effects.