The invention discloses a transformer with an anti-theft alarm function, and the transformer is fixedly arranged at the bottom of a containing cavity; a lock cylinder is rotationally connected into a lock hole, one end of the lock cylinder extends into a control cavity and is fixedly connected with a first rotating gear, a first push rod is slidably arranged in a first push rod cavity, and a second push rod is slidably arranged in a second push rod cavity. The electromagnet is embedded above the first push rod cavity, the positioning rod is slidably arranged in the positioning hole, the closing mechanism is fixedly arranged in the transmission cavity, the baffle is slidably arranged in the baffle cavity and fixedly connected with the closing mechanism, the Bluetooth module is embedded in the inner side of the door plate, the pressure switch is fixedly arranged on the top wall of the transmission cavity, and the alarm mechanism is fixedly arranged on the top of the anti-theft shell. The second push rod is completely sucked into the second push rod cavity through the electromagnet, so a thief cannot unlock the lock by shifting the push rod, the anti-theft effect is achieved, and when the thief pries the baffle plate forcibly, the pressure switch is triggered, the alarm mechanism is started, and the aim of frightening the thief is achieved.