Abstract: A nail gun includes a motor and a driving mechanism that are optimally arranged to achieve continuous and efficient hammering within a compact structure. In one embodiment, the nail gun includes a chassis comprising a handle and a muzzle; a cylinder within an upper part of the chassis; a piston within the cylinder; an anvil within the muzzle; a motor within the handle; a rotation-linear motion conversion mechanism comprising a pendulum bearing for connecting the piston and the motor and converting a rotation of the motor into a linear motion of the piston; wherein the piston is configured to drive the air hammer to impact the nail continuously through the pin.