Method for manufacturing an optical sensor, the method comprising: - providing an optical sensor arrangement which comprises at least two optical sensor elements on a carrier, where the optical sensor arrangement comprises a light entrance surface at the side of the optical sensor elements facing away from the carrier, - forming a trench between two optical sensor elements in a vertical direction (z) which is perpendicular to the main plane of extension of the carrier, where the trench extends from the light entrance surface of the optical sensor arrangement at least to the carrier, - completely filling the trench with an opaque material, - forming electrical contacts for the at least two optical sensor elements on a back side of the carrier facing away from the optical sensor elements, - forming at least one optical sensor by dicing the optical sensor arrangement along the trench after the trench is filled with the opaque material, where - a handling substrate is arranged at the back side of the carrier during forming the trench and during filling the trench with the opaque material, the handling substrate being a tape that is expanded in a lateral direction (x) after forming the trench and before filling the trench with the opaque material, wherein the lateral direction (x) is parallel to the main plane of extension of the carrier, wherein - each optical sensor has an opaque coating, that is formed by the opaque material, at its side surfaces and comprises an optical sensor element, and - the light entrance surface is free of electrical contacts and at least partially free of the opaque material above the optical sensor elements. - providing an optical sensor arrangement which comprises at least two optical sensor elements on a carrier, where the optical sensor arrangement comprises a light entrance surface at the side of the optical sensor elements facing away from the carrier, - forming a trench between two optical sensor elements in a vertical direction (z) which is perpendicular to the main plane of extension of the carrier, where the trench extends from the light entrance surface of the optical sensor arrangement at least to the carrier, - completely filling the trench with an opaque material, - forming electrical contacts for the at least two optical sensor elements on a back side of the carrier facing away from the optical sensor elements, - forming at least one optical sensor by dicing the optical sensor arrangement along the trench after the trench is filled with the opaque material, where - a handling substrate is arranged at the back side of the carrier during forming the trench and during filling the trench with the opaque material, the handling substrate being a tape that is expanded in a lateral direction (x) after forming the trench and before filling the trench with the opaque material, wherein the lateral direction (x) is parallel to the main plane of extension of the carrier, wherein - each optical sensor has an opaque coating, that is formed by the opaque material, at its side surfaces and comprises an optical sensor element, and - the light entrance surface is free of electrical contacts and at least partially free of the opaque material above the optical sensor elements.