Lycium barbarum by-products (LBPs), including residual branches, leaves and fruits generated during processing, are rich in bioactive compounds exhibiting antioxidant, anti-inflammatory and immunomodulatory properties. However, their efficient utilization remains limited. This study investigated the effects of fermentation duration on the chemical composition and bioactivity of LBPs. Anaerobic solid-state fermentation was conducted using a mixed microbial consortium of Bacillus subtilis PFK1702, Lactobacillus, and yeast for 0 (CON), 3 (F3) and 5 (F5) days. Fermentation significantly altered the nutritional composition of LBPs, increasing crude protein and total polyphenol contents while reducing crude fat and crude fiber levels (P < 0.05). Nontargeted metabolomics identified 16 flavonoid metabolites, including 6,7,8-tetrahydroxy-5-methoxyflavone, diosmetin, rhamnocitrin, hispidulin, nepetin, luteolin-7-O-glucoside (cynaroside) and others. Most flavonoid metabolites were upregulated in F3 and F5 compared with CON, with the highest accumulation observed after 5 days of fermentation. KEGG pathway enrichment analysis indicated that luteolin-7-O-glucoside (cynaroside) may participate in the flavonoid biosynthetic pathway of LBPs, although further experimental validation is needed. Overall, prolonged fermentation enhanced flavonoid biosynthesis and improved the nutritional and functional properties of LBPs, suggesting that a 5-day fermentation period is optimal. These results offer theoretical and practical insights into the valorization of LBPs as functional feed or natural antioxidant resources.