The ferulic acid (FA) is a kind of phenolic acid widely exists in nature plants. Apart from its medicinal values, the FA is also widely applied in cosmetic industry. Recently, it was found to have potential applications in commercial sunscreens for its strong photostability and photoprotection property from harmful UV rays. Such excellent property lies in the ultrafast decay process of the FA system when exposure to the UV light, but the underlying detailed relaxation pathway is still less clear-cut. In the current work, high-level ab initio electronic structure calculations and on-the-fly surface hopping dynamics simulations were employed to explore the photoinduced decay mechanism of the FA system both on the S1 and S3 states in the gas phase. The results provide a reasonable explanation for the wavelength dependent decay patterns of FA system. The S1 state decay pathway is driven by a re-emission process to dissipate excess energy. While for the S3 state deactivation process, the pathway is dominated by a non-adiabatic process driven by the internal conversion process through the conical intersection regions. A S3-S1-S0 two step decay pattern is proposed, and the pathways are mainly driven by a puckering distortion motion of the aromatic ring and a twisting motion around the bridging double bond. The calculation results contribute to a better understanding of detailed dynamics behavior of the FA deactivation process, and provide theoretical guidance for further design of efficient and environmentally friendly sunscreens.