The free-energy difference is a fundamental equilibrium property of a molecule, because it determines molecule's thermodynamic stability and its folding pathways. Here, we develop and use a single-molecule nanopore pulling technique to measure the free-energy difference of DNA hairpins and other folded molecules. We use alpha-hemolysin nanopore to pull through and unfold DNA hairpins with a time-dependent voltage-induced perturbation. Within the stochastic thermodynamics framework, we describe a molecule in a nanopore with a perturbed Hamiltonian, calibrate the system, and further estimate the stochastic work to unfold by integrating the dissipated electric power during the pulling time. The change in the free energy is obtained from the average work to unfold in the slow limit or through the Jarzynski work-fluctuation theorem at finite times.