The photochemical decomposition of 1,2,4-oxadiazole-3,5-diamine and 1,2,4-thiadiazole-3,5-diamine was investigated in low-temperature Ar and Kr matrixes at different wavelengths. The analysis of matrix-isolation infrared (MI-IR) spectra aided by high-level quantum chemical computations showed not only that these photochemical reactions yield [NH, C, N, X] (X = O, S) isomers but also that the bands of a novel, formerly unobserved species were observed. The comparison of computed IR spectra of potential products with the observed spectra suggests that these species are the diazenecarbaldehyde (HNNCHO) and diazenecarbothialdehyde (HNNCHS). Neither of the reactive HNNCHO and HNNCHS molecules was observed experimentally before. Both molecules are identified in the matrix as a complex with the other photoproduct, NHCN. Comparison of the present experiments with former photochemical experiments on 1,2,5-oxadiazole-3,4-diamine and 1,2,5-thiadiazole-3,4-diamine and the analysis of the rate of formation of the different photoproducts indicate that HNNCHO and HNNCHS are formed in a different reaction path than HNNCX and HNC(NX) (X = O, S), and not by photoisomerization from these latter products.