The inner porosity of tablets plays an important role in its disintegration characteristics, and then affects its efficacy. However, few researches have been reported to detect tablets porosity so far. The quantitative relationship between the porosity, refractive index and the indomethacin mass fraction of mixed tablets composed by microcrystalline cellulose (MCC) and indomethacin (API) is studied using terahertz spectroscopy based on the time delay effect of terahertz pulse, and its mathematical model is built. The porosity and reflective index are calculated by measuring terahertz spectrum of the tablets. The results show that the relationship between porosity and reflective index or mass fractions of different compositions is a linear correlation, which is consistent with the mathematical model. The average relative error of porosity obtained by terahertz spectroscopy and gas replacement method is 6.0%, and the average relative error of porosity obtained by terahertz spectroscopy and density method is 8.9%. The terahertz spectroscopy can be used to measure the porosity of the tablet, and it is a supplementary measure in monitoring the quality of the tablets.