Abstract: Grid cells in the medial entorhinal cortex construct an intriguing multiperiodic representation of space whose properties have been the subject of much theoretical speculation. Here we combine theoretical arguments and analyses of entorhinal cortex population recordings to show that the grid cell representation is ideally set up to decorrelate and assign easily distinguishable labels to inputs, thus potentially acting as a pattern separation device, much like hash functions in computer science. The multiple modules of the grid cell system allow the threshold for pattern separation to be flexibly controlled. This flexible pattern separation ability could serve to enhance episodic memory in the hippocampal formation by reducing interference between similar patterns in a controllable way.