This study introduces a biosensor system designed for the rapid and specific detection of Bacillus subtilis (B. subtilis) in various food matrices, addressing the critical need for enhanced food safety measures. Recognizing the global prevalence of foodborne illnesses and the role of B. subtilis as a contributor, this research focused on developing a sensor capable of operating effectively in complex food environments such as rice and milk. The biosensor, utilizing an alginate-gelatin layer, demonstrated a high degree of specificity and sensitivity, distinguishing B. subtilis from other common foodborne pathogens like Bacillus licheniformis (B. licheniformis), Bacillus cereus (B. cereus), and Escherichia coli (E. coli). Through rigorous testing, the biosensor showed a distinct and rapid response to B. subtilis, even at lower bacterial concentrations, highlighting its potential for early detection of contamination. The study also explored the sensor's response across different food types, revealing the influence of food composition on pathogen detection efficacy. The results confirmed the biosensor's capability to adapt to varying food matrices, maintaining accuracy and reliability. This research contributes to the field of food safety, offering a practical solution for timely pathogen detection. The development of this biosensor represents a step forward in ensuring food quality and public health, providing a tool for the food industry to identify and mitigate potential contamination risks rapidly. These findings provide a foundation for the development of advanced on-site testing technologies, potentially enhancing food safety protocols and practices.