A sulfur smell in urine is most often the result of eating asparagus, says WebMD. This is due to the breakdown of methyl mercaptan and other sulfur compounds in asparagus.
Asparagus contains asparagusic acid, which breaks down into various sulfur-containing compounds, such as dimethyl sulfide, upon digestion, says Smithsonian. Similar compounds are responsible for the pungent odor of garlic and skunk spray. These sulfur compounds are volatile and enter their gaseous phase at room temperature, releasing odor as soon as urine comes into contact with air. Asparagusic acid is not volatile, so the vegetable itself does not produce the same odor. Asparagusic acid breaks down quickly, however, and sulfur compounds appear in urine as soon as 15 minutes after consuming asparagus.
Not all individuals experience sulfurous urine after consuming asparagus, reports Smithsonian. Studies from the 1980s indicate that this is due to some individuals lacking the ability to detect the odor, even though the do produce it. However, a newer study suggests that some individuals really do not produce the sulfur compounds at all. The reason for this is unclear, but an inability to perceive the odor is due to a single switched base pair among a group of olfactory-related genes.