Aims Nitrate content in crops might be affected by soil abiotic properties and endophytic and soil microbes. This study aimed to reveal the effects of spent mushroom substrate (SMS) and nitrification inhibitor dicyandiamide (DCD) and 3,4-dimethylpyrazole phosphate (DMPP) on the nitrate content of pepper fruit and to link the nitrate with soil abiotic properties and endophytic and soil bacterial communities. Methods Our current study contained four different treatments: blank control (CK); sole SMS application (SAA); SMS + DCD (SDCD); and SMS + DMPP (SDMPP). The nitrate contents and bacterial communities in fruit, root and soil samples were quantified and linked. Results Compared with the CK treatment, the nitrate contents of pepper fruit decreased by 43.2%, 66.8% and 64.4% in the SAA, SDCD and SDMPP treatments, respectively. The combined applications of SMS and nitrification inhibitors significantly enhanced the pH and bacterial community diversity of soil samples. The SMS applications significantly changed bacterial community structures in the soils and roots rather than in the fruit. The relative abundances of aerobic chemoheterotrophy function in the fruit samples were 0.28, 0.17, 0.10 and 0.15 for the CK, SAA, SDCD and SDMPP treatments, respectively. The relative abundances of Bacteroidetes and aerobic chemoheterotrophy were significantly and positively correlated with nitrate contents in the fruit. Conclusions Apart from promoting fruit yield, the SMS and nitrification inhibitor applications could also decrease the health risk of crop nitrate accumulation via affecting the soil pH, ammonium content and endophytic bacterial community diversity, structures and functions in fruit samples.