An optical sensor comprising: a case; a light projecting module that comprises a light emitting unit, a light projecting lens, and a light projecting lens holder unit configured to hold the light projecting lens; a light receiving unit configured to receive reflected light of light projected from the light projecting module; and a light receiving lens unit configured to form an image of the reflected light on the light receiving unit, wherein the light projecting module, the light receiving unit, and the light receiving lens unit are each independently and directly fixed to the case, wherein, in the light projecting module, the light projecting lens is held by and fixed to the light projecting lens holder unit isotropically with respect to directions perpendicular to an optical axis defined by the light projecting lens and the light emitting unit, the light receiving lens unit comprises a light receiving lens and a light receiving lens holder configured to hold the light receiving lens, the light receiving lens is held by and fixed to the light receiving lens holder isotropically with respect to directions perpendicular to an optical axis defined by the light receiving lens and the light receiving unit, and a base, the light projecting lens holder unit, and the light receiving lens holder are all made of a resin or a glass-fiber reinforced resin, wherein the light projecting module comprises: a light projecting unit holder in which the light emitting unit and the light projecting lens are accommodated, wherein the light projecting unit holder comprises the light projecting lens holder unit; and a holding member configured to fix the light emitting unit accommodated in the light projecting unit holder, the holding member and the light projecting lens are fixed to the light projecting unit holder using an ultraviolet-curing adhesive, where the light projecting lens can be slid in the light projecting lens holder unit so that the distance from the light emitting unit to the projecting lens can be adjusted before the light projecting lens is fixed. a case; a light projecting module that comprises a light emitting unit, a light projecting lens, and a light projecting lens holder unit configured to hold the light projecting lens; a light receiving unit configured to receive reflected light of light projected from the light projecting module; and a light receiving lens unit configured to form an image of the reflected light on the light receiving unit, wherein the light projecting module, the light receiving unit, and the light receiving lens unit are each independently and directly fixed to the case, wherein, in the light projecting module, the light projecting lens is held by and fixed to the light projecting lens holder unit isotropically with respect to directions perpendicular to an optical axis defined by the light projecting lens and the light emitting unit, the light receiving lens unit comprises a light receiving lens and a light receiving lens holder configured to hold the light receiving lens, the light receiving lens is held by and fixed to the light receiving lens holder isotropically with respect to directions perpendicular to an optical axis defined by the light receiving lens and the light receiving unit, and a base, the light projecting lens holder unit, and the light receiving lens holder are all made of a resin or a glass-fiber reinforced resin, a light projecting unit holder in which the light emitting unit and the light projecting lens are accommodated, wherein the light projecting unit holder comprises the light projecting lens holder unit; and a holding member configured to fix the light emitting unit accommodated in the light projecting unit holder, the holding member and the light projecting lens are fixed to the light projecting unit holder using an ultraviolet-curing adhesive, where the light projecting lens can be slid in the light projecting lens holder unit so that the distance from the light emitting unit to the projecting lens can be adjusted before the light projecting lens is fixed.