High-resolution nuclear magnetic resonance (NMR) spectroscopy is a powerful analytical tool with wide applications. However, the conventional shim technique may not guarantee the homogeneity of the magnetic field when the experimental conditions are unfavorable. In this study, we proposed a data postprocessing method called Restore High-resolution Unet (RH-Unet), which uses a convolutional neural network to restore distorted NMR spectra that have been acquired in inhomogeneous magnetic fields. The method generates feature-label pairs from singlet peak regions and ideal Lorentzian line shapes and trains a RH-Unet model to map low-resolution spectra to high-resolution spectra. The method was applied to different samples and showed superior performance than the reference deconvolution method incorporated in Bruker Topspin software. The proposed method provides a simple and fast way to obtain high-resolution NMR spectra in inhomogeneous fields that can facilitate the application of NMR spectroscopy in various fields.