We show how a qubit can be fault-tolerantly encoded in the infinite-dimensional Hilbert space of an optical mode. The scheme is efficient and realizable with present technologies. In fact, it involves two travelling optical modes coupled by a cross-Kerr interaction, initially prepared in coherent states, one of which is much more intense than the other. At the exit of the Kerr medium, the weak mode is subject to a homodyne measurement and a quantum codeword is conditionally generated in the quantum fluctuations of the intense mode.