It’s not generally done like in One Flew Over the Cuckoo’s Nest. The pulses, voltages, and currents are apparently small and precise.
More recently, “transcranial magnetic stimulation” has been reported similarly effective and seems to be considered something of an evolution beyond ECT, using magnetic fields instead of electric current, and avoiding the need for sedation etc.
I don’t fully understand it all, and I gather there are still a lot of questions about the exact mechanism. The research done so far is said to support some beneficial outcomes in hard-to-treat cases.
As with so many mental health issues, however, doing rigorous double blind studies for example is difficult or impossible.
Anyway, better practice is no longer to just strap people in and shock people in the brain.