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. Here, PTPN1 is linked to obesity due to melanocortin 4 receptor deficiency.