Since September 2014, NASA's Orbiting Carbon Observatory-2 (OCO-2) satellite has been taking measurements of reflected solar spectra and using them to infer atmospheric carbon dioxide levels. This work provides details of the OCO-2 retrieval algorithm, versions 7 and 8, used to derive the column-Averaged dry air mole fraction of atmospheric CO2 (XCO2 ) for the roughly 100 000 cloud-free measurements recorded by OCO-2 each day. The algorithm is based on the Atmospheric Carbon Observations from Space (ACOS) algorithm which has been applied to observations from the Greenhouse Gases Observing SATellite (GOSAT) since 2009, with modifications necessary for OCO-2. Because high accuracy, better than 0.25 %, is required in order to accurately infer carbon sources and sinks from XCO2 , significant errors and regional-scale biases in the measurements must be minimized. We discuss efforts to filter out poor-quality measurements, and correct the remaining goodquality measurements to minimize regional-scale biases. Updates to the radiance calibration and retrieval forward model in version 8 have improved many aspects of the retrieved data products. The version 8 data appear to have reduced regionalscale biases overall, and demonstrate a clear improvement over the version 7 data. In particular, error variance with respect to TCCON was reduced by 20% over land and 40% over ocean between versions 7 and 8, and nadir and glint observations over land are now more consistent. While this paper documents the significant improvements in the ACOS algorithm, it will continue to evolve and improve as the CO2 data record continues to expand.