Magnets themselves do not generate electricity, but they can be used in generators to convert mechanical energy into electrical energy through electromagnetic induction.