Gray codes are broadly used as the cyclic codes to assist error correction in optical communications. In this paper, we have proposed the novel design of three different types of all-optical gray code converters based on the semiconductor optical amplifier (SOA) Mach-Zehnder interferometer (MZI) configuration. The XOR and OR gates are the basic devices used for the proposed design of binary to gray, binary-coded decimal (BCD) to gray, and octal to binary code converters. For the first time, to the best of the authors' knowledge, a high data rate of 500 Gbps is achieved for the three types of all-optical code converters using the SOA-MZI configuration by exploiting an M-ary differential phase shift keying (DPSK) modulation scheme. The performance factors of the proposed all-optical code converters like extinction ratio, bit error rate, and quality factor are calculated.