An X-ray detector includes a converter element and a carrier element in a stack arrangement. In an embodiment, the X-ray detector further includes a light source arranged on the carrier element, a light-directing unit formed outside a projection of a planar extension of the converter element in the stacking direction, and a light-directing unit arranged such that a quantity of light emitted from the light source is incident on a surface of the converter element, facing away from the carrier element via a light path.