An optical encoder is comprised of three component parts, which are an emission-side light-pervious resin 6 by which a light emitting chip 1 is sealed, a reception-side light-pervious resin 8 by which a light receiving chip 2 is sealed, and an outer casing 4 to which a lens 3 is integrated and in which the emission-side light-pervious resin 6 and the reception-side light-pervious resin 8 are housed. Thus, the optical encoder can be reduced in parts count, allowing the development cost to be reduced, as compared with the case where the lens 3 for collimating light derived from the light emitting chip 1 and the outer casing 4 are provided as independent component parts.