Conventional headspace‐based analysis is not suitable for identifying volatile compounds in fresh onion (Allium cepa L.) because large amounts of water vapor could affect the determination of target compounds. A headspace‐trap was introduced to remove water vapor and keep the analytes in the trap tube. Additionally, the headspace‐trap method based on room‐temperature enrichment could prevent enzyme‐sensitive samples from denaturing to maintain the original flavor compositions of the samples. Moreover, the highly volatile compounds were poorly separated after headspace extraction. By using a cryotrapping device, these compounds were well separated. Therefore, a room‐temperature enrichment headspace‐trap cryotrapping gas chromatography with mass spectrometric method was established for the determination of volatile compounds in fresh onion. With this method, a total of 73 volatile compounds were identified by mass spectral search and retention index. Among them, 29 highly volatile compounds were successfully separated before the retention time of 5 min, and these compounds contributed significantly to the smell of onion. The volatile compounds were dominated by dipropyl disulfide (35.42%), 1,2‐dithiolane (15.82%), 1‐propanethiol (11.74%) and propanal (11.23%). The results indicated that the proposed method was an effective tool for analyzing volatile compounds in high‐water‐content fresh onion samples.