The x-ray transform I integrates a function fon over lines. The range characterization of the x-ray transform on the Schwartz space is well known, the main ingredient of the characterization is some system of second order differential equations that are called John's equations. The Reshetnyak formula equates the norm to some special norm of If, it was also known before. We prove a new version of the Reshetnyak formula that involves first order derivatives of If with respect to the ξ-variable. On using the latter formula, we obtain the range characterization of the x-ray transform on Sobolev spaces.