The analysis of the x-ray spectrum obtained in electron cyclotron resonance ͑ECR͒ x-ray source is carried out. Assuming single-particle motion, the electron acceleration and its final energy are calculated for TE 111 cylindrical cavity field and uniform external dc magnetic field. In the calculation, initial coordinates of 40 000 electrons were uniformly selected over the central plane of the cavity using random number generator. The final energy of each electron when it hits the wall is stored and the electron energy distribution is obtained. Using the general purpose Monte Carlo N-particle transport code version 4A, the geometry of the ECR x-ray source is modeled. The x-ray energy spectrum is calculated for the geometry model and the numerically calculated electron energy distribution. The calculated x-ray spectrum is compared with the experimentally measured x-ray spectrum.