The cultural and geographical properties of the environment have been shown to deeply influence cognition and mental health1–6. Living near green spaces has been found to be strongly beneficial7–11, and urban residence has been associated with a higher risk of some psychiatric disorders12–14—although some studies suggest that dense socioeconomic networks found in larger cities provide a buffer against depression15. However, how the environment in which one grew up affects later cognitive abilities remains poorly understood. Here we used a cognitive task embedded in a video game16 to measure non-verbal spatial navigation ability in 397,162 people from 38 countries across the world. Overall, we found that people who grew up outside cities were better at navigation. More specifically, people were better at navigating in environments that were topologically similar to where they grew up. Growing up in cities with a low street network entropy (for example, Chicago) led to better results at video game levels with a regular layout, whereas growing up outside cities or in cities with a higher street network entropy (for example, Prague) led to better results at more entropic video game levels. This provides evidence of the effect of the environment on human cognition on a global scale, and highlights the importance of urban design in human cognition and brain function.