An n-bit (cyclic) Gray code is a (cyclic) sequence of all n-bit strings such that consecutive strings differ in a single bit. We describe an algorithm which for every positive integer n constructs an n-bit cyclic Gray code whose graph of transitions is the d-dimensional hypercube Qd if n = 2d , or a subgraph of Qd if 2d−1 < n < 2d . This allows to compress sequences that follow this code so that only Θ(log log n) bits per n-bit string are needed.