Developing axons grow through brain tissue to reach their targets — a process termed pathfinding. The regulation of this process involves chemical cues, but it is not known whether the mechanical forces encountered by the axon as it grows through brain tissues also play a part. Here, Koser et al. show that, in Xenopus laevis, the growing axons of retinal ganglion cells express the mechanosensitive ion channel piezo 1, which detects differences in tissue stiffness and, as a result, promotes the trajectory of axon growth towards softer tissues.