Comets are frozen remnants of our solar system’s formation, and comparing their chemical composition to that of planet-forming systems can reveal crucial insights about our origins, potentially answering one of the most challenging questions in planetary science, i.e., whether cometary material was mainly inherited from the protosolar nebula or reprocessed during the solar system formation. Here we provide the first statistical analysis of methanol, formaldehyde, and ammonia abundances in 35 comets and 11 protostellar solar analogs and planet-forming disks. We show that comets from different dynamical families have comparable compositions on average, implying that their chemistry is preserved even after formation. While abundances retrieved from infrared and (sub)millimeter ground-based observations are in agreement, there are significant differences with those obtained via mass spectroscopy for 67P/Churyumov–Gerasimenko, target of the ESA-Rosetta mission; we discuss the implication of relying solely on the latter data for comparisons with disk abundance ratios. Finally, we find a significant difference in the [CH3OH]/[H2CO] ratio in comets observed within or farther than 1 au from the Sun, suggesting that temperature-activated mechanisms can enhance the H2CO production in the coma; this bias can strongly influence our understanding of comet chemistry in the context of planet formation. When compared to planet-forming systems, the [CH3OH]/[H2CO] and [NH3]/[CH3OH] molecular abundance ratios in comets are consistent with those measured in Class 0 hot corinos and in the inner regions of Class II disks, hence suggesting an inheritance scenario.