A generator is a device that converts mechanical energy into electrical energy. It works on the principle of electromagnetic induction, where the motion of a magnetic field around a conductor produces an electrical current. Generators are used in a variety of applications, ranging from providing backup power during outages to powering equipment in remote locations.