Tomatoes, an essential crop in controlled environments, benefit significantly from the careful use of nitrogen fertilizers, which are crucial for improving both yield and nitrogen efficiency. Using a tomato pot experiment arranged in a facility greenhouse, five treatments were established as follows: a control excluding the application of nitrogen fertilizer (C), and applications of ammonium nitrogen and nitrate nitrogen with nitrogen mass ratios of 0:100 (A0N100), 25:75 (A25N75), 50:50 (A50N50), 75:25 (A75N25), and 100:0 (A100N0), to study the effects of different ratios of nitrogen mass on tomato yield, quality, nutrient accumulation, and nitrogen fertilizer utilization. The results showed that compared with C, the different ammonium–nitrate ratios significantly increased the yield, dry matter mass, N, P, and K accumulation, soluble solids, soluble sugars, and vitamin C content (Vc) of the tomatoes. Among all the treatments, A75N25 tomatoes had the highest dry matter accumulation, nitrogen, phosphorus, and potassium accumulation in fruits, soluble sugar, and soluble solids content. The differences in tomato yield and nitrogen fertilizer utilization between A75N25 and A100N0 were insignificant but their values were significantly higher than those of the other treatments. A75N25 had the highest nitrogen fertilizer utilization rate, 42.1% to 82.3% higher than C, A25N75, and A50N50. Hence, an ammonium-to-nitrate nitrogen mass ratio of 75:25 optimized tomato yield and quality in a controlled environment while minimizing nutrient loss.