Formamide (NH 2 CHO) has been proposed as a pre-biotic precursor with a key role in the emergence of life on Earth. While this molecule has been observed in space, most of its detections correspond to high-mass star-forming regions. Motivated by this lack of investigation in the low-mass regime, we searched for formamide, as well as isocyanic acid (HNCO), in 10 low-and intermediate-mass pre-stellar and protostellar objects. The present work is part of the IRAM Large Programme ASAI (Astrochemical Surveys At IRAM), which makes use of unbiased broadband spectral surveys at millimetre wavelengths. We detected HNCO in all the sources and NH 2 CHO in five of them. We derived their abundances and analysed them together with those reported in the literature for high-mass sources. For those sources with formamide detection, we found a tight and almost linear correlation between HNCO and NH 2 CHO abundances, with their ratio being roughly constant -between 3 and 10-across 6 orders of magnitude in luminosity. This suggests the two species are chemically related. The sources without formamide detection, which are also the coldest and devoid of hot corinos, fall well off the correlation, displaying a much larger amount of HNCO relative to NH 2 CHO. Our results suggest that, while HNCO can be formed in the gas phase during the cold stages of star formation, NH 2 CHO forms most efficiently on the mantles of dust grains at these temperatures, where it remains frozen until the temperature rises enough to sublimate the icy grain mantles. We propose hydrogenation of HNCO as a likely formation route leading to NH 2 CHO.