Using first-principles calculations, we investigate the electronic structures and binding properties of nicotine and caffeine adsorbed on single-walled carbon nanotubes to determine whether CNTs are appropriate for filtering or sensing nicotine and caffeine molecules. We find that caffeine adsorbs more strongly than nicotine. The different binding characteristics are discussed by analyzing the modification of the electronic structure of the molecule-adsorbed CNTs. We also calculate the quantum conductance of the CNTs in the presence of nicotine or caffeine adsorbates and demonstrate that the influence of caffeine is stronger than nicotine on the conductance of the host CNT.