It works on the principle of mutual induction of two coils or Faraday Law’s of Electromagnetic induction. When the current in the primary coil is changed the flux linked to the secondary coil also changes. Hence an EMF is induced in the secondary coil due to Faraday laws of electromagnetic induction.
The transformer is based on two principles: first, that an electric current can produce a magnetic field (electromagnetism), and, second that a changing magnetic field within a coil of wire induces a voltage across the ends of the coil. Changing the current in the primary coil changes the magnetic flux that is developed. The changing magnetic flux induces a voltage in the secondary coil.