With the attention focused on harvesting energy from the ambient environment for nanoscale electronic devices, electromechanical coupling effects in materials have been studied for many potential applications. Flexoelectricity can be observed in all dielectric materials, coupling the strain gradients and polarization, and may lead to strong size-dependent effects at the nanoscale. This paper investigates the flexoelectric energy harvesting under the harmonic mechanical excitation, based on a model similar to the classical Euler–Bernoulli beam theory. The electric Gibbs free energy and the generalized Hamilton’s variational principle for a flexoelectric body are used to derive the coupled governing equations for flexoelectric beams. The closed-form electromechanical expressions are obtained for the steady-state response to the harmonic mechanical excitation in the flexoelectric cantilever beams. The results show that the voltage output, power density, and mechanical vibration response exhibit significant scale effects at the nanoscale. Especially, the output power density for energy harvesting has an optimal value at an intrinsic length scale. This intrinsic length is proportional to the material flexoelectric coefficient. Moreover, it is found that the optimal load resistance for peak power density depends on the beam thickness at the small scale with a critical thickness. Our research indicates that flexoelectric energy harvesting could be a valid alternative to piezoelectric energy harvesting at micro- or nanoscales.