Ammonia (NH3) in exhaled breath (EB) has been a biomarker for kidney function, and accurate measurement of NH3 is essential for early screening of kidney disease. In this work, we report an optical sensor that combines ultraviolet differential optical absorption spectroscopy (UV-DOAS) and spectral reconstruction fitting neural network (SRFNN) for detecting NH3 in EB. UV-DOAS is introduced to eliminate interference from slow change absorption in the EB spectrum while spectral reconstruction fitting is proposed for the first time to map the original spectra onto the sine function spectra by the principle of least absolute deviations. The sine function spectra are then fitted by the least-squares method to eliminate noise signals and the interference of exhaled nitric oxide. Finally, the neural network is built to enable the detection of NH3 in EB at parts per billion (ppb) level. The laboratory results show that the detection range is 9.50-12425.82 ppb, the mean absolute percentage error (MAPE) is 0.83%, and the detection accuracy is 0.42%. Experimental results prove that the sensor can detect breath NH3 and identify EB in simulated patients and healthy people. Our sensor will serve as a new and effective system for detecting breath NH3 with high accuracy and stability in the medical field.