Successful application of the Hadamard transform (HT) technique to gas chromatography/mass spectrometry (GC/MS) and liquid chromatography/mass spectrometry (LC/MS) is described. Novel sample injection devices were developed to achieve multiple sample injections in both GC and LC instruments. Air pressure was controlled by an electromagnetic valve in GC, while a syringe pump and Tee connector were employed for the injection device in LC. Two well-known, abused drugs, 3,4-methylenedioxy-N-methylamphetamine (MDMA) and N, N-dimethyltryptamine (DMT), were employed as model samples. Both of the injection devices permitted precise successive injections, resulting in clearly modulated chromatograms encoded by Hadamard matrices. After inverse Hadamard transformation of the encoded chromatogram, the signal-to-noise (S/N) ratios of the signals were substantially improved compared with those expected from theoretical values. The S/N ratios were enhanced approximately 10-fold in HT-GC/MS and 6.8 in HT-LC/MS, using the matrices of 1023 and 511, respectively. The HT-GC/MS was successfully applied to the determination of MDMA in the urine sample of a suspect.