Electric nail guns work by using a rotating electric motor that compresses a powerful spring to generate rather than compressed air used by pneumatic nail guns. When the trigger is pulled, the spring is released, creating the force used to drive the nail into the material.