Vagus nerve stimulation (VNS) is thought to alter the state of the brain by recruiting global neuromodulators. VNS is used in treatment-resistant epilepsy, and is increasingly being explored for other brain disorders, such as depression, and as a cognitive enhancer. However, the promise of VNS is only partially fulfilled due to a lack of mechanistic understanding of the transfer function between stimulation parameters and neuromodulatory response, together with a lack of biosensor for assaying stimulation efficacy in real time. We here develop an approach to VNS in head-fixed mice on a treadmill, and use it to show that pupil dilation is a biosensor for VNS-evoked cortical neuromodulation. In a 'goldilocks' zone of stimulation parameters, current leakage and off-target effects are minimized and the extent of pupil dilation tracks VNS-evoked basal-forebrain cholinergic axon activity in auditory cortex. Thus, pupil dilation is a sensitive readout of the moment-by-moment titratable effects of VNS on brain state.