A rapid analytical method based on online solid-phase extraction with high-performance liquid chromatography and mass spectrometry has been established and applied to the determination of tannin compounds that may cause adverse effects in traditional Chinese medicine injections. Different solid-phase extraction sorbents have been compared and the elution buffer was optimized. The performance of the method was verified by evaluation of recovery (≥40%), repeatability (RSD ≤ 6%), linearity (r(2) ≥ 0.993), and limit of quantification (≤0.35 μg/mL). Five tannin compounds, gallic acid, cianidanol, gallocatechin gallate, ellagic acid, and penta-O-galloylglucose, were identified with concentrations ranging from 3.1-37.4 μg/mL in the analyzed traditional Chinese medicine injections.