Graphene nanoribbons—narrow and straight-edged stripes of graphene, or single-layer graphite—are predicted to exhibit electronic properties that make them attractive for the fabrication of nanoscale electronic devices1, 2, 3. In particular, although the two-dimensional parent material graphene4, 5 exhibits semimetallic behaviour, quantum confinement and edge effects2, 6 should render all graphene nanoribbons with widths smaller than 10 nm semiconducting. But exploring the potential of graphene nanoribbons is hampered by their limited availability: although they have been made using chemical7, 8, 9, sonochemical10 and lithographic11, 12 methods as well as through the unzipping of carbon nanotubes13, 14, 15, 16, the reliable production of graphene nanoribbons smaller than 10 nm with chemical precision remains a significant challenge. Here we report a simple method for the production of atomically precise graphene nanoribbons of different topologies and widths, which uses surface-assisted coupling17, 18 of molecular precursors into linear polyphenylenes and their subsequent cyclodehydrogenation19, 20. The topology, width and edge periphery of the graphene nanoribbon products are defined by the structure of the precursor monomers, which can be designed to give access to a wide range of different graphene nanoribbons. We expect that our bottom-up approach to the atomically precise fabrication of graphene nanoribbons will finally enable detailed experimental investigations of the properties of this exciting class of materials. It should even provide a route to graphene nanoribbon structures with engineered chemical and electronic properties, including the theoretically predicted intraribbon quantum dots21, superlattice structures22 and magnetic devices based on specific graphene nanoribbon edge states3.