A transformer works on the principle of electromagnetic induction. It consists of two coils, a primary coil and a secondary coil, which are magnetically coupled. The alternating current in the primary coil creates a changing magnetic field, which induces an alternating current in the secondary coil.