Significance Functional near-infrared spectroscopy (fNIRS) presents an opportunity to study human brains in everyday activities and environments. However, achieving robust measurements under such dynamic conditions remains a significant challenge. Aim The modular optical brain imaging (MOBI) system is designed to enhance optode-to-scalp coupling and provide a real-time probe three-dimensional (3D) shape estimation to improve the use of fNIRS in everyday conditions. Approach The MOBI system utilizes a bendable and lightweight modular circuit-board design to enhance probe conformity to head surfaces and comfort for long-term wearability. Combined with automatic module connection recognition, the built-in orientation sensors on each module can be used to estimate optode 3D positions in real time to enable advanced tomographic data analysis and motion tracking. Results Optical characterization of the MOBI detector reports a noise equivalence power of 8.9 and 7.3pW/√Hz at 735 and 850 nm, respectively, with a dynamic range of 88 dB. The 3D optode shape acquisition yields an average error of 4.2 mm across 25 optodes in a phantom test compared with positions acquired from a digitizer. Results for initial in vivo validations, including a cuff occlusion and a finger-tapping test, are also provided. Conclusions To the best of our knowledge, the MOBI system is the first modular fNIRS system featuring fully flexible circuit boards. The self-organizing module sensor network and automatic 3D optode position acquisition, combined with lightweight modules ( 18g/module) and ergonomic designs, would greatly aid emerging explorations of brain function in naturalistic settings.