Nuclear magnetic resonance imaging (MRI) at the atomic scale offers exciting prospects for determining the structure and function of individual molecules and proteins. Quantum defects in diamond have recently emerged as a promising platform towards reaching this goal, and allowed for the detection and localization of single nuclear spins under ambient conditions. Here, we present an efficient strategy for extending imaging to large nuclear spin clusters, fulfilling an important requirement towards a single-molecule MRI technique. Our method combines the concepts of weak quantum measurements, phase encoding and simulated annealing to detect three-dimensional positions from many nuclei in parallel. Detection is spatially selective, allowing us to probe nuclei at a chosen target radius while avoiding interference from strongly-coupled proximal nuclei. We demonstrate our strategy by imaging clusters containing more than 20 carbon-13 nuclear spins within a radius of 2.4 nm from single, near-surface nitrogen–vacancy centers at room temperature. The radius extrapolates to 5–6 nm for 1H. Beside taking an important step in nanoscale MRI, our experiment also provides an efficient tool for the characterization of large nuclear spin registers in the context of quantum simulators and quantum network nodes.