Nestmate recognition in ants is based on perceived differences in a multi-component blend of hydrocarbons that are present on the insect cuticle. Although supplementation experiments have shown that some classes of hydrocarbons, such as methyl branched alkanes and alkenes, have a salient role in nestmate recognition, there was basically no information available on how ants detect and perceive these molecules. We used a new conditioning procedure to investigate whether individual carpenter ants could associate a given hydrocarbon (linear or methyl-branched alkane) to sugar reward. We then studied perceptual similarity between a hydrocarbon previously associated with sugar and a novel hydrocarbon. Ants learnt all hydrocarbon-reward associations rapidly and with the same efficiency, regardless of the structure of the molecules. Ants could discriminate among a large number of pairs of hydrocarbons, but also generalised. Generalisation depended both on the structure of the molecule and the animal’s experience. For linear alkanes, generalisation was observed when the novel molecule was smaller than the conditioned one. Generalisation between pairs of methyl-alkanes was high, while generalisation between hydrocarbons that differed in the presence or absence of a methyl group was low, suggesting that chain length and functional group might be coded independently by the ant olfactory system. Understanding variations in perception of recognition cues in ants is necessary for the general understanding of the mechanisms involved in social recognition processes based on chemical cues.