Non-Abelian braiding has attracted substantial attention because of its pivotal role in describing the exchange behaviour of anyons—candidates for realizing quantum logics. The input and outcome of non-Abelian braiding are connected by a unitary matrix that can also physically emerge as a geometric-phase matrix in classical systems. Hence it is predicted that non-Abelian braiding should have analogues in photonics, although a feasible platform and the experimental realization remain out of reach. Here we propose and experimentally realize an on-chip photonic system that achieves the non-Abelian braiding of up to five photonic modes. The braiding is realized by controlling the multi-mode geometric-phase matrix in judiciously designed photonic waveguide arrays. The quintessential effect of braiding—sequence-dependent swapping of photon dwell sites—is observed in both classical-light and single-photon experiments. Our photonic chips are a versatile and expandable platform for studying non-Abelian physics, and we expect the results to motivate next-generation non-Abelian photonic devices. Non-Abelian braiding—a candidate for realizing quantum logics—is demonstrated by controlling the geometric-phase matrix in a photonic chip, and its key characteristics are observed.