Many laptop chargers have a noticeable block in the middle of the cable. People often call it a "power brick", and inside, it is actually a small power supply similar to the one inside a desktop PC.
The main reason it exists is because the electricity from a wall outlet is not the type a laptop can use directly.
Electricity from the wall is usually alternating current (AC) and the voltage is quite high. Depending on the country, it may be around 100 to 240 volts. A laptop, however, normally runs on low-voltage direct current (DC), often somewhere around 19 or 20 volts.
$ads={1}
So the charger has to change the electricity before it reaches the laptop.
Inside the power brick are several electronic parts that handle this job. One part changes the AC electricity from the wall into DC. Another part reduces the voltage to a much lower level that the laptop expects. There are also components that smooth and regulate the power so it stays stable instead of jumping around.
The charger is also designed to handle different levels of power use. A laptop does not always need the same amount of electricity. When it is idle, it may use less power. When it is doing heavy work, it may draw more. The charger can provide enough power for these changes, while the laptop itself decides how much it actually takes.
Modern chargers often use a type of design called a switch-mode power supply. In simple terms, the circuit turns the power on and off very quickly and then adjusts it to the correct voltage. This method is more efficient and helps keep the charger smaller than older designs.
The power brick is kept outside the laptop instead of being built inside it. There are a few practical reasons for that. Power conversion creates heat, so placing the circuit outside keeps extra heat away from the laptop’s internal parts. The components also take up space and add weight, which is not ideal for a portable device.
Another benefit is convenience. If the charger fails, it can usually be replaced without opening the laptop. Manufacturers can also sell the same charger in different countries and only change the wall cable or plug.
Because of all that, the small block on the cable is not just a connector. It is doing the work of turning wall electricity into the type of power the laptop can safely use.
Source: Reddit
