In this study, magnetic N-doped carbon dots (N-C-dots) are fabricated employing a straightforward pyrolysis method at 300 degrees C for distinct time frames of 1, 2, and 3 h using onion (Allium cepa) as carbon source for the decontamination of methylene blue (MB) and rhodamine B (RhB) dyes. The as-obtained N-C-dots were examined using a wide spectrum of techniques, including X-ray diffraction (XRD), UV-visible, Raman spectroscopy, Scanning electron microscope (SEM), high-resolution transmission electron microscopic (HRTEM), X-ray photoelectron spectroscopy (XPS), Fourier transform infrared (FTIR) spectroscopy, vibrating-sample magnetometry (VSM), and photoluminescence spectroscopy (PL). The resulting N-C-dots are highly crystalline, almost sphere-like, and are of paramagnetic nature, with particle sizes in the range of 2.53 to 15.97 nm. The Raman spectrum's distinctive peaks assisted in confirming the production of C-dots and calculating their purity level. As the pyrolysis duration increased from 1 to 3 h, the optical band gap values of the N-C-dots decreased from 2.91 to 2.61 eV. Additionally, by degrading MB dye up to 92.76% and RhB dye up to 83.05% under visible light exposure with a rise in pyrolysis duration, the as-obtained N-C-dots demonstrated outstanding abilities to be employed as photocatalysts and can be helpful for wastewater decontamination.