Measuring neuronal tuning curves has been instrumental for many discoveries in neuroscience but requires a priori assumptions regarding the identity of the encoded variables. We applied unsupervised learning to large-scale neuronal recordings in behaving mice from circuits involved in spatial cognition and uncovered a highly-organized internal structure of ensemble activity patterns. This emergent structure allowed defining for each neuron an ‘internal tuning-curve’ that characterizes its activity relative to the network activity, rather than relative to any predefined external variable, revealing place-tuning and head-direction tuning without relying on measurements of place or head-direction. Similar investigation in prefrontal cortex revealed schematic representations of distances and actions, and exposed a previously unknown variable, the ‘trajectory-phase’. The internal structure was conserved across mice, allowing using one animal’s data to decode another animal’s behavior. Thus, the internal structure of neuronal activity itself enables reconstructing internal representations and discovering new behavioral variables hidden within a neural code.