Heightened spontaneous activity in sensory neurons is often reported in individuals living with chronic pain. It is possible to study this activity in rodents using electrophysiology, but these experiments require great skill and can be prone to bias. Here, we have examined whether in vivo calcium imaging with GCaMP6s can be used as an alternative approach. We show that spontaneously active calcium transients can be visualised in the fourth lumbar dorsal root ganglion (L4 DRG) through in vivo imaging in a mouse model of inflammatory pain. Application of lidocaine to the nerve, between the inflamed site and the DRG, silenced spontaneous firing and revealed the true baseline level of calcium for spontaneously active neurons. We used these data to train a machine learning algorithm to predict when a neuron is spontaneously active. We show that our algorithm is accurate in 2 different models of pain: intraplantar complete Freund adjuvant and antigen-induced arthritis, with accuracies of 90.0% ±1.2 and 85.9% ±2.1, respectively, assessed against visual inspection by an experienced observer. The algorithm can also detect neuronal activity in imaging experiments generated in a different laboratory using a different microscope configuration (accuracy = 94.0% ±2.2). We conclude that in vivo calcium imaging can be used to assess spontaneous activity in sensory neurons and provide a Google Colaboratory Notebook to allow anyone easy access to our novel analysis tool, for the assessment of spontaneous neuronal activity in their own imaging setups.