We know that the planes (h k l) are the planes which are perpendicular to the vector (h, k, l). Thus, their equations are:
$$hx+ky+lz=D$$, in which D is a real number.
But these planes have to pass through atoms of the crystal. So, $$D=na$$, where a is the lattice parameter and n is a natural number (e.g., 1, 2, 3, ...). So, the planes have the equation:
One way to derive the formula is to use reciprocal space coordinates. The reciprocal space lattice has three unit cell vectors, a*, b* and c*. The diffraction vector d* is given by:
$$d^* = h a^* + k b^* + h c^*$$
The d-spacing is given by the reciprocal length of d*. The relationship between direct space and reciprocal space unit cell ...