Cefazolin is an antibiotic used to treat a wide variety of bacterial infections. It may also be used before and during certain surgeries to help prevent infection. This medication is known as a cephalosporin antibiotic. It works by stopping the growth of bacteria.