Nuclear magnetic resonance (NMR) spectroscopy is a key analytical technique in chemistry, biology, and medicine. However, conventional NMR spectroscopy requires an at least nanoliter-sized sample volume to achieve sufficient signal. We combined the use of a quantum memory and high magnetic fields with a dedicated quantum sensor based on nitrogen vacancy centers in diamond to achieve chemical shift resolution in 1H and 19F NMR spectroscopy of 20-zeptoliter sample volumes. We demonstrate the application of NMR pulse sequences to achieve homonuclear decoupling and spin diffusion measurements. The best measured NMR linewidth of a liquid sample was ~1 part per million, mainly limited by molecular diffusion. To mitigate the influence of diffusion, we performed high-resolution solid-state NMR by applying homonuclear decoupling and achieved a 20-fold narrowing of the NMR linewidth.