A small relaxation of the axisymmetric magnetic field of a tokamak into a non-axisymmetric three-dimensional (3D) configuration can be effective to control magnetohydrodynamic instabilities, such as edge-localized modes. However, a major challenge to the concept of 3D tokamaks is that there are virtually unlimited possible choices for a 3D magnetic field, and most of them will only destabilize or degrade plasmas by symmetry breaking. Here, we demonstrate the phase-space visualization of the full 3D field-operating windows of a tokamak, which allows us to predict which configurations will maintain high confinement without magnetohydrodynamic instabilities in an entire region of plasmas. We test our approach at the Korean Superconducting Tokamak Advanced Research (KSTAR) facility, whose 3D coils with many degrees of freedom in the coil space make it unique for this purpose. Our experiments show that only a small subset of coil configurations can accomplish edge-localized mode suppression without terminating the discharge with core magnetohydrodynamic instabilities, as predicted by the perturbative 3D expansion of plasma equilibrium and the optimizing principle of local resonance. The prediction provided excellent guidance, implying that our method can substantially improve the efficiency and fidelity of the 3D optimization process in tokamaks.