Most behavior is organized in a serial manner. However, how a sequence is mentally stored in memory remains largely unknown. We investigated the neural code underlying sequence working memory using two-photon calcium imaging to record thousands of neurons in the prefrontal cortex of macaque monkeys memorizing and then reproducing a sequence of locations after a delay. We found a unified geometrical pattern across sequences in the neural state space: 1) The high-dimensional neural state space during the delay could be decomposed into disentangled low-dimensional subspaces, each storing the spatial location at a given ordinal rank. 2) Crucially, theses independent rank subspaces could be generalized to novel and variable length sequences. 3) Furthermore, monkey behavior could be explained by this compositional code. 4) The rank subspaces were distributed across large overlapping neural subgroups. 5) The integration of ordinal and spatial information occurred at the collective level rather than within single neurons. Our data thus provided the neural evidence of disentangled representation for sequence working memory.