Herein, we investigate sulfur substitutional defects in single-walled carbon nanotubes (SWCNTs) and graphene by using first-principles calculations. The estimated formation energies for the (3,3), (5,5), and (10,0) SWCNTs and graphene lie between 0.9 and 3.8 eV, at sulfur concentrations of 1.7-4 atom %. Thus, from a thermodynamic standpoint, sulfur doping is not difficult. Indeed, these values can be compared with that of 0.7 eV obtained for a nitrogen-doped (5,5) SWCNT. We suggest that it may be possible to introduce sulfur into the SWCNT framework by employing sulfur-containing heterocycles. Our simulations indicate that sulfur doping can modify the electronic structure of the SWCNTs and graphene, depending on the sulfur content. In the case of graphene, sulfur doping can induce different effects: the doped sheet can be a small-band-gap semiconductor, or it can have better metallic properties than the pristine sheet. Thus, S-doped graphene may be a smart choice for constructing nanoelectronic devices, since it is possible to modulate the electronic properties of the sheet by adjusting the amount of sulfur introduced. Different synthetic routes to produce sulfur-doped graphene are discussed.