Tomato is sweet and sour and has high nutritional value. Soluble solids content (SSC) and organic acid content are important quality indexes of tomato fruit. The exogenous supply of different forms of nitrogen can have different effects on plant growth and development and physiological and metabolic processes because of the different mechanisms of nitrogen uptake and assimilation in plants. In the paper, different concentrations of nitrogen were used to study tomatoes' physical and chemical characteristics and appearance. Hyperspectral imaging (HSI) technology was employed to predict tomatoes' SSC and acid content. Competitive adaptive reweighed sampling (CARS), uninformative variable elimination (UVE),variable combination population analysis (VCPA), iteratively retaining informative variables (IRIV), and interval variable iterative spatial shrinkage analysis (IVISSA) were used to extract the feature wavelengths. Based on the characteristic wavelength, the prediction models of tomato SSC and organic acid content were established by partial least squares regression (PLSR), multiple linear regression (MLR) and principal component regression (PCR). Then a custom convolutional neural network (CNN) model was constructed and optimised. The results showed that the SSC of tomato was negatively correlated with nitrogen fertilizer concentration, and the highest organic acid content was recorded under the T4 treatment. For tomatoes treated with different nitrogen concentrations, the CARS-PLSR model showed the best results for tomato SSC, with RC and RP of 0.8589 and 0.8499 and RMSEC and RMSEP of 0.3180 and 0.3407. The IRIV-PCR model for organic acids was the best, with RC and RP reaching 0.8011 and 0.7760 and RMSEC and RMSEP reaching 0.6181 and 0.7055. Among all the models, the performance obtained by the CNN model was satisfactory. This study provides technical support for future online nondestructive testing of tomato quality.