X-ray radiation dose delivered during cancer external-beam radiotherapy (EBRT) is nonlinear with the biological effect imparted to cancer cells and neighboring healthy tissues. This oftentimes leads to insufficient damage to cancer cells and excessive damage to the surrounding healthy tissues, both increasing toxicity and the risk of cancer recurrence later in life for many patients. An understanding of X-ray energy deposition at the single-X-ray level is, therefore, necessary to improve the efficacy of cancer radiotherapy. Here, we present a single-X-ray sensitive, energy-binning integrated circuit (IC)-based dosimeter, fabricated in 180 nm CMOS technology, to enable closed-loop cancer radiotherapy for personalized patient treatment. We use small 3 x 3 mu m reverse-biased deep n-well (DNWELL) diodes designed at low capacitive nodes (C-diode), such that the miniscule charge deposition (Q(dep)) from single X-rays at these nodes generates a voltage signal large enough to be sensed (V-diode = Q(dep)/C-diode). In order to enable single-X-ray energy resolution without significant power and area, we implement an analog voltage supply (AVDDH) similar to log resistor grid to create a sensitivity gradient across the 76 x 55 pixel array. The IC-based dosimeter was tested under scenarios consistent with the treatment of shallow lesions (e.g., skin cancer, superficial tumors, intraoperative radiotherapy). The system is highly linear with radiation dose (10-250 cGy) and accurately tracks dose up to 2 cm deep in tissue for 50-, 70-, and 100-kV X-ray beams.