Livestock production in China is increasingly located near urban areas, exposing human populations to nitrogen pollution via air and water. Here we analyse livestock and human population data across 2,300 Chinese counties to project the impact of alternative livestock distributions on nitrogen emissions. In 2012 almost half of China's livestock production occurred in peri-urban regions, exposing 60% of the Chinese population to ammonia emissions exceeding UN guidelines. Relocating 5 billion animals by 2050 according to crop-livestock integration criteria could reduce nitrogen emissions by two-thirds and halve the number of people exposed to high ammonia emissions. Relocating 10 billion animals away from southern and eastern China could reduce ammonia exposure for 90% of China's population. Spatial planning can therefore serve as a powerful policy instrument to tackle nitrogen pollution and exposure of humans to ammonia. © The Author(s), under exclusive licence to Springer Nature Limited 2022.