We present an all-optical mass spectrometry technique to identify trapped ions. The new method uses laser-cooled ions to determine the mass of a cotrapped dark ion with a sub-dalton resolution within a few seconds. We apply the method to identify the first controlled synthesis of cold, trapped RaOH+ and RaOCH3+. These molecules are promising for their sensitivity to time and parity violations that could constrain sources of new physics beyond the standard model. The nondestructive nature of the mass spectrometry technique may help identify molecular ions or highly charged ions prior to optical spectroscopy. Unlike previous mass spectrometry techniques for small ion crystals that rely on scanning, the method uses a Fourier transform that is inherently broadband and comparatively fast. The technique’s speed provides new opportunities for studying state-resolved chemical reactions in ion traps.