A generator is a device that converts mechanical energy to electrical energy for use in an external circuit. Generators provide nearly all of the power for electric power grids.