Inline optical sensor which includes a modular flowcell block with a flow passageway of predetermined diameter, interchangeable adapters for connecting flow lines with different internal diameters to the block, and an optical pathlength that can be adjusted both in fixed increments with window spacers and continuously with vernier adjusters, and a light source and an optical detector in modular housings which can be aligned both radially and axially. Thermal isolation is provided between the housings and the flowcell body, and air circulation further reduces temperature and condensation within the housings.