We prove an analogue of the magnetic nodal theorem on quantum graphs: the number of zeros $phi$ of the $n$-th eigenfunction of the Schrodinger operator on a quantum graph is related to the stability of the $n$-th eigenvalue of the perturbation of the operator by magnetic potential. More precisely, we consider the $n$-th eigenvalue as a function of the magnetic perturbation and show that its Morse index at zero magnetic field is equal to $phi - (n-1)$.