In everyday life, rolling motion is typically associated with cylindrical (for example, car wheels) or spherical (for example, billiard balls) bodies tracing linear paths. However, mathematicians have, for decades, been interested in more exotically shaped solids such as the famous oloids1, sphericons2, polycons3, platonicons4 and two-circle rollers5 that roll downhill in curvilinear paths (in contrast to cylinders or spheres) yet indefinitely (in contrast to cones, Supplementary Video 1). The trajectories traced by such bodies have been studied in detail6,7,8,9, and can be useful in the context of efficient mixing10,11 and robotics, for example, in magnetically actuated, millimetre-sized sphericon-shaped robots12,13, or larger sphericon- and oloid-shaped robots translocating by shifting their centre of mass14,15. However, the rolling paths of these shapes are all sinusoid-like and their diversity ends there. Accordingly, we were intrigued whether a more general problem is solvable: given an infinite periodic trajectory, find the shape that would trace this trajectory when rolling down a slope. Here, we develop an algorithm to design such bodies—which we call ‘trajectoids’—and then validate these designs experimentally by three-dimensionally printing the computed shapes and tracking their rolling paths, including those that close onto themselves such that the body’s centre of mass moves intermittently uphill (Supplementary Video 2). Our study is motivated largely by fundamental curiosity, but the existence of trajectoids for most paths has unexpected implications for quantum and classical optics, as the dynamics of qubits, spins and light polarization can be exactly mapped to trajectoids and their paths16.