Context. Formamide (HCONH 2 ) is the simplest molecule with a peptide bond detected in the interstellar medium. One of the keys for understanding the mechanisms for forming formamide in massive hot cores is the comparison of the relative abundances of its deuterated isotopologues. Aims. No deuterated species of formamide have been detected to date mostly owing to the lack of laboratory spectral data, which is limited by cm-wave measurements up to 40 GHz. Therefore, we decided to extend the measurements and the analysis of the rotational spectra of deuterated istopologues of formamide into the terahertz range. Methods. We measured the rotational spectra of deuterated formamide in the frequency range 150-950 GHz using the Lille fast-scan and solid-state source spectrometers. Results. The ground vibrational states of 4 different isotopologues of formamide, DCONH 2 , cis-HCONHD, trans-HCONHD, and HCOND 2 , were assigned and analysed. The sets of the rotational and centrifugal distortion constants we obtained allow us to calculate accurate predictions of the transition frequencies for deuterated formamide in the frequency range above 1 THz and at least for J < 65 and K a < 25.