The characterization of elastic properties of biopolymers is crucial to understand many molecular reactions determined by conformational bending fluctuations of the polymer. Direct measurement of such elastic properties using single-molecule methods is usually hindered by the intrinsic tendency of such biopolymers to form high-order molecular structures. For example, single-stranded deoxyribonucleic acids (ssDNA) tend to form secondary structures such as local double helices that prevent the direct measurement of the ideal elastic response of the ssDNA. In this work, we show how to extract the ideal elastic response in the entropic regime of short ssDNA molecules by mechanically pulling two-state DNA hairpins of different contour lengths. This is achieved by measuring the force dependence of the molecular extension and stiffness on mechanically folding and unfolding the DNA hairpin. Both quantities are fit to the worm-like chain elastic model giving values for the persistence length and the interphosphate distance. This method can be used to unravel the elastic properties of short ssDNA and RNA sequences and, more generally, any biopolymer that can exhibit a cooperative two-state transition between mechanically folded and unfolded states (such as proteins).