Ultraviolet (UV) photodissociation of CO controls the abundances and distribution of CO and its photodissociation products. This significantly influences the gas-phase chemistry in the circumstellar envelope (CSE) around evolved stars. A better understanding of CO photodissociation in outflows also provides a more precise estimate of mass-loss rates. We aim to update the CO photodissociation rate in an expanding spherical envelope assuming that the interstellar radiation field (ISRF) photons penetrate through the envelope. This will allow us to precisely estimate the CO abundance distributions in CSEs around evolved stars. We used the most recent CO spectroscopic data to precisely calculate the depth dependency of the photodissociation rate of each CO dissociating line. We calculated the CO self- and mutual-shielding functions in an expanding envelope. We investigated the dependence of the CO profile on the five fundamental parameters mass-loss rate, the expansion velocity, the CO initial abundance, the CO excitation temperature, and the strength of the ISRF. Our derived CO envelope size is smaller than the commonly used radius derived by Mamon et al. 1988. The difference between results varies from 1% to 39% and depends on the H2 and CO densities of the envelope. We list two fitting parameters for a large grid of models to estimate the CO abundance distribution. We demonstrate that the CO envelope size can differ between outflows with the same effective content of CO, but different CO abundance, mass-loss rate, and the expansion velocity as a consequence of differing amounts of shielding by H2 and CO. We find that the abundance of CO close to the star and the outflow density both can have a significant effect on the size of the molecular envelope. We also demonstrate that modest variations in the ISRF can cause measurable differences in the envelope extent.