Context. Hydrogen is the most abundant molecule in the Universe. Its thermodynamic quantities dominate the physical conditions in molecular clouds, protoplanetary disks, etc. It is also of high interest in plasma physics. Therefore thermodynamic data for molecular hydrogen have to be as accurate as possible in a wide temperature range. Aims. We here rigorously show the shortcomings of various simplifications that are used to calculate the total internal partition function. These shortcomings can lead to errors of up to 40 percent or more in the estimated partition function. These errors carry on to calculations of thermodynamic quantities. Therefore a more complicated approach has to be taken. Methods. Seven possible simplifications of various complexity are described, together with advantages and disadvantages of direct summation of experimental values. These were compared to what we consider the most accurate and most complete treatment (case 8). Dunham coefficients were determined from experimental and theoretical energy levels of a number of electronically excited states of H 2 . Both equilibrium and normal hydrogen was taken into consideration. Results. Various shortcomings in existing calculations are demonstrated, and the reasons for them are explained. New partition functions for equilibrium, normal, and ortho and para hydrogen are calculated and thermodynamic quantities are reported for the temperature range 1-20 000 K. Our results are compared to previous estimates in the literature. The calculations are not limited to the ground electronic state, but include all bound and quasi-bound levels of excited electronic states. Dunham coefficients of these states of H 2 are also reported. Conclusions. For most of the relevant astrophysical cases it is strongly advised to avoid using simplifications, such as a harmonic oscillator and rigid rotor or ad hoc summation limits of the eigenstates to estimate accurate partition functions and to be particularly careful when using polynomial fits to the computed values. Reported internal partition functions and thermodynamic quantities in the present work are shown to be more accurate than previously available data.