This technology uses M13 bacteriophage to serve as a template for carbon nanofiber synthesis. The inventors engineered a M13 capsid protein to serve as a template for nanofiber self-assembly. The two-step nanofiber synthesis begins by using M13 phage to nucleate formation of resorcinol-formaldehyde (RF) nanofibers. In the second step, the RF nanofibers are carbonized to yield carbon nanofibers with uniform shape and a very small diameter. Importantly, both the nanofiber morphology and surface nanotexture can be tuned by altering the M13 nucleation moiety or the composition of the RF mixture, respectively. The inventors demonstrate that these microporous carbon nanofibers can be used as an interlayer in lithium-sulfur batteries to greatly increase the discharge capacity and retain capacity after repeated cycling. Additionally, these carbon nanofibers show promise as a therapeutic treatment of toxin exposure, and proof of concept experiments demonstrate these nanofibers are superior to activated carbon in adsorbing toxins.