Here we develop a minimally disruptive optical approach to control protein tyrosine phosphatase 1B (PTP1B)—an important regulator of receptor tyrosine kinases and a therapeutic target for the treatment of diabetes, obesity, and cancer—and we use that approach to probe the intracellular function of this enzyme. This evidence concerns the gene PTPN1 and diabetes mellitus.