During eye development, retinal ganglion cells (RGCs) extend axons that connect the photoreceptors to the brain. In organisms with binocular vision, these axons grow until they reach a region of the brain called the optic chiasm, where they either project to the same side of the brain (ipsilateral axons) or cross the chiasm to reach the opposite side of the brain (contralateral axons). The chemokine CXCL12 can promote axon extension, but whether it contributes to axon guidance at the optic chiasm is unclear. Here, Lynda Erskine, Christiana Ruhrberg and colleagues perform in situ hybridisation in embryonic mouse retinas to demonstrate that Cxcl12 is expressed in the ventral diencephalon meninges, which neighbours the optic chiasm. Meanwhile, the gene encoding CXCL12’s receptor, CXCR4, is expressed in both ipsilateral and contralateral axons. Using mouse retinal explants, the authors show that exposure to CXCL12 or to pieces of the ventral diencephalon meninges promotes RGC axon outgrowth in vitro. Mouse embryos lacking either CXCL12 or CXCR4 have an increased proportion of ipsilateral axons compared with their wild-type siblings. Overall, this work identifies CXCL12 as a key factor in promoting RGC axon growth across the optic chiasm and the formation of contralateral projections.