Unsustainable straw treatment methods detrimentally affect the environment and ecology. Aerobic fermentation (AE) and anaerobic fermentation (AN) are environmentally friendly treatments that better utilise straw resources. In this study, high-throughput sequencing was used to investigate the effects of AE and AN on nutrient content and microbial community structure during tomato straw fermentation. Nitrate nitrogen, available phosphorus, available potassium, and fulvic acid contents following AE were 1250.04 mg/kg, 80.34 %, 161.39 %, and 49.31 %, respectively, which were higher than those following AN. Ammonium nitrogen, humic acid, and humic substance levels following AN were 309.07 %, 31.18 %, and 17.38 %, respectively, which were higher than those following AE. Firmicutes (24.76 %) and Actinobacteria (12.93 %) were more abundant following AE, whereas Proteobacteria (33.82 %) and Bacteroidetes (33.82 %) exhibited higher abundance following AN. AE more effectively eliminated pathogenic bacteria (22.01%–0.26 %) and encouraged stronger interactions between dominant bacterial genera. Redundancy and Mantel test analyses revealed that electrical conductivity and temperature were the most important environmental factors affecting bacterial communities in AE and AN, respectively. AE had a stronger effect on effective nutrient release from tomato straw, implying its greater application potential as a fertiliser. Overall, our study provides a theoretical basis for the optimisation of fermentation methods and processes.