A color-coded projection grating is used to provide means of measuring 3D surface profiles. In conventional 24 bits RGB model, each color has 256 gray levels, whereas we use only the levels of 0 and 255 to maximize the difference of gray levels. Thus there are eight colors which can be used to code the grating. They are white, red, green, blue, cyan, magenta, yellow, and black. In order to get a large space period grating, we code the grating on a specific order. If we use eight kinds of colors to code the grating, we can get 64 strips in one period. In this case the space period of the projection grating is large enough in the most of measurement of surface profiles. Only one image is needed in 3D measurement and so it is suitable for on-line inspection. In our system the measurement error is less than +/- 1.3 mm.