We present the first part of a project on the global energetics of solar flares and coronal mass ejections (CMEs) that includes about 400 M- and X-class flares observed with AIA and HMI onboard SDO. We calculate the potential energy, free energy, and the flare-dissipated magnetic energy. We calculate these magnetic parameters using two different NLFFF codes: The COR-NLFFF code uses the line-of-sight magnetic field component $B_z$ from HMI to define the potential field, and the 2D coordinates of automatically detected coronal loops in 6 coronal wavelengths from AIA to measure the helical twist of coronal loops caused by vertical currents, while the PHOT-NLFFF code extrapolates the photospheric 3D vector fields. We find agreement between the two codes in the measurement of free energies and dissipated energies within a factor of $ \approx 3$. The size distributions of magnetic parameters exhibit powerlaw slopes that are approximately consistent with the fractal-diffusive self-organized criticality model. The magnetic parameters exhibit scaling laws for the nonpotential energy, $E_{np} \propto E_p^{1.02}$, for the free energy, $E_{free} \propto E_p^{1.7}$ and $E_{free} \propto B_{\varphi}^{1.0} L^{1.5}$, for the dissipated energy, $E_{diss} \propto E_p^{1.6}$ and $E_{diss} \propto E_{free}^{0.9}$, and the energy dissipation volume, $V \propto E_{diss}^{1.2}$. The potential energies vary in the range of $E_p = 1 \times 10^{31} - 4 \times 10^{33}$ erg, while the free energy has a ratio of $E_{free}/E_p \approx 1%-25%$. The Poynting flux amounts to $F_{flare} \approx 5 \times 10^{8} - 10^{10}$ erg cm$^{-2}$ s$^{-1}$ during flares, which averages to $F_{AR} \approx 6 \times 10^6$ erg cm$^{-2}$ s$^{-1}$ during the entire observation period and is comparable with the coronal heating rate requirement in active regions.