Flow is a subjective state characterized by immersion and engagement in one’s current activity. The benefits of flow for productivity and health are well-documented, but a rigorous description of the flow-generating process remains elusive. Here we develop and empirically test a theory of flow’s computational substrates: the informational theory of flow. Our theory draws on the concept of mutual information, a fundamental quantity in information theory that quantifies the strength of association between two variables. We propose that the mutual information between desired end states and means of attaining them — 𝐼(𝑀;𝐸) — gives rise to flow. We support our theory across five experiments (four preregistered) by showing, across multiple activities, that increasing 𝐼(𝑀;𝐸) increases flow and has important downstream benefits, including enhanced attention and enjoyment. We rule out alternative constructs including alternative metrics of associative strength, psychological constructs previously shown to predict flow, and various forms of instrumental value.