Synchronization of coupled oscillators is important for understanding collective dynamics of a variety of natural and artificial systems including Josephson junctions, neuronal networks, and power grids. Despite this ubiquity, it remains unclear how the interaction between oscillator’s dynamics and coupled structure either promotes or inhibits synchrony. Here, we introduce a unified Lyapunov function to Kuramoto systems such that it can be readily optimized to enhance synchrony of even heterogeneous oscillators on sparse networks. We demonstrate its efficacy in frequency allocation and network design on both synthetic network models and empirical power grids. This new criterion circumventes the calculation of the eigenvalues and eigenvectors of the network Laplacian, and thus is a high efficient framework for optimizing synchronization of large oscillator networks.