We model the intensity of emission lines from the CO molecule, based on hydrodynamic simulations of spirals, mergers, and highredshift galaxies with very high resolutions (3 pc and 10 3 M ) and detailed models for the phase-space structure of the interstellar gas including shock heating, stellar feedback processes, and galactic winds. The simulations are analyzed with a large velocity gradient (LVG) model to compute the local emission in various molecular lines in each resolution element, radiation transfer, opacity effect, and the intensity emerging from galaxies to generate synthetic spectra for various transitions of the CO molecule. This model reproduces the known properties of CO spectra and CO-to-H 2 conversion factors in nearby spirals and starbursting major mergers. The high excitation of CO lines in mergers is dominated by an excess of high-density gas, and the high turbulent velocities and compression that create this dense gas excess result in broad linewidths and low CO intensity-to-H 2 mass ratios. When applied to high-redshift gas-rich disks galaxies, the same model predicts that their CO-to-H 2 conversion factor is almost as high as in nearby spirals, and much higher than in starbursting mergers. High-redshift disk galaxies contain giant star-forming clumps that host a high-excitation component associated to gas warmed by the spatially concentrated stellar feedback sources, although CO(1−0) to CO(3−2) emission is dominated overall by low-excitation gas around the densest clumps. These results generally highlight a strong dependence of CO excitation and the CO-to-H 2 conversion factor on galaxy type, even at similar star formation rates or densities. The underlying processes are driven by the interstellar medium structure and turbulence and its response to stellar feedback, which depend on global galaxy structure and in turn affect the CO emission properties.