Generating synthetic locomotory and electrophysiological data is a necessary yet cumbersome step required to study theoretical models of the brain's role in spatial navigation. This process can be time consuming and, without a common framework, makes it difficult to reproduce or compare studies which each generate test data in different ways. In response we present RatInABox, an open-source Python toolkit designed to model realistic rodent locomotion and generate synthetic electrophysiological data from spatially modulated cell types. This software provides users with (i) the ability to construct one- or two-dimensional environments with configurable barriers and rewards, (ii) a realistic motion model for random foraging fitted to experimental data (iii) rapid online calculation of neural data for some of the known self-location or velocity selective cell types in the hippocampal formation (including place cells, grid cells, boundary vector cells, head direction cells) and (iv) a framework for constructing custom cell types as well as multi-layer network models. Cell activity and the motion model are spatially and temporally continuous and topographically sensitive to boundary conditions and walls. We demonstrate that out-of-the-box parameter settings replicate many aspects of rodent foraging behaviour such as velocity statistics and the tendency of rodents to over-explore walls. Numerous tutorial scripts are provided, including examples in which RatInABox is used for decoding position from neural data, reinforcement learning, or to set up an example circuit capable of learning path integration. We hope this tool significantly streamlines the process of theory-driven research into the brain's role in navigation.