Caffeine is an alkaloid and may be the most commonly ingested pharmacologically active substance in the world, but continuous abuse may lead to "caffeine poisoning". In this study, we propose a method for the qualitative and quantitative analysis of caffeine in various medicines using terahertz spectroscopy combined with chemometrics. By comparing this terahertz (THz) spectroscopy technology (Fourier transform infrared instrument, FTIR) with high performance liquid chromatography (HPLC) and Raman spectroscopy, we prove that there is less than a 5% difference between the THz and HPLC results, which is far superior to the nondestructive testing results obtained using Raman spectroscopy. In addition, the quantitative analysis of caffeine in 86 medicines was conducted using the support vector regression (SVR) chemometric method, and the correlation coefficient R achieves 99.61%. Therefore, we have effectively proven that THz spectroscopy technology combined with chemometric can achieve nondestructive, fast, and efficient qualitative and quantitative detection of key ingredients in medicines.