As sand moves across Earth's landscapes, the shapes of individual grains evolve, and microscopic textures accumulate on their surfaces. Because transport processes vary between environments, the shape and suite of microtextures etched on sand grains provide insights into their transport histories. For example, previous efforts to link microtextures to transport environments have demonstrated that they can provide important information about the depositional environments of rocks with few other indicators. However, such analyses rely on 1) subjective human description of microtextures, which can yield biased, error-prone results; 2) nonstandard lists of microtextures; and 3) relatively large sample sizes (>20 grains) to obtain reliable results, the manual documentation of which is extremely labor intensive. These drawbacks have hindered broad adoption of the technique. We address these limitations by developing a deep neural network model, SandAI, that classifies scanning electron microscope images of modern sand grains by transport environment with high accuracy. The SandAI model was developed using images of sand grains from modern environments around the globe. Training data encompass the four most common terrestrial environments: fluvial, eolian, glacial, and beach. We validate the model on quartz grains from modern sites unknown to it, and Jurassic-Pliocene sandstones of known depositional environments. Next, the model is applied to two samples of the Cryogenian Bråvika Member (of contested origin), yielding insights into periglacial systems associated with Snowball Earth. Our results demonstrate the robustness and versatility of the model in quickly and automatically constraining the transport histories recorded in individual grains of quartz sand.