Fractionalization is a phenomenon in which strong interactions in a quantum system drive the emergence of excitations with quantum numbers that are absent in the building blocks. Outstanding examples are excitations with charge e/3 in the fractional quantum Hall effect1,2, solitons in one-dimensional conducting polymers3,4 and Majorana states in topological superconductors5. Fractionalization is also predicted to manifest itself in low-dimensional quantum magnets, such as one-dimensional antiferromagnetic S = 1 chains. The fundamental features of this system are gapped excitations in the bulk6 and, remarkably, S = 1/2 edge states at the chain termini7,8,9, leading to a four-fold degenerate ground state that reflects the underlying symmetry-protected topological order10,11. Here, we use on-surface synthesis12 to fabricate one-dimensional spin chains that contain the S = 1 polycyclic aromatic hydrocarbon triangulene as the building block. Using scanning tunnelling microscopy and spectroscopy at 4.5 K, we probe length-dependent magnetic excitations at the atomic scale in both open-ended and cyclic spin chains, and directly observe gapped spin excitations and fractional edge states therein. Exact diagonalization calculations provide conclusive evidence that the spin chains are described by the S = 1 bilinear-biquadratic Hamiltonian in the Haldane symmetry-protected topological phase. Our results open a bottom-up approach to study strongly correlated phases in purely organic materials, with the potential for the realization of measurement-based quantum computation13.