Searches for the exclusive decays of the Higgs and Z bosons into a J/?,?(2S), or ?(nS)(n=1,2,3) meson and a photon are performed with a pp collision data sample corresponding to an integrated luminosity of 36.1 fb -1 collected at vs =13 TeV with the ATLAS detector at the CERN Large Hadron Collider. No significant excess of events is observed above the expected backgrounds, and 95% confidence-level upper limits on the branching fractions of the Higgs boson decays to J/??, ?(2S)?,and ?(nS)? of 3.5×10 -4, 2.0×10-3,and(4.9,5.9,5.7)×10 -4,respectively, are obtained assuming Standard Model production. The corresponding 95% confidence-level upper limits for the branching fractions of the Z boson decays are 2.3×10 -6, 4.5×10 -6 and (2.8,1.7,4.8)×10 -6, respectively.