Switch off a relay coil drawing 100 milliamps with nothing to catch its energy, and a circuit simulation run for this post produced a spike of about 491,000 volts on the switch. That number is fiction, because a real transistor would break down long before it got there, but the physics pushing toward it is not. Add a single diode across the coil and the peak fell to 12.9 volts. A diode is the simplest semiconductor there is, a one-way valve for current, and that one job turns up in power supplies, logic circuits, LED drivers and every relay board on a hobbyist’s bench.
A one-way valve with a toll
Forward and reverse
A diode conducts readily in one direction, from anode to cathode, and blocks current in the other. The stripe painted on a diode’s body marks the cathode. Put it in backward and a circuit that should work does nothing; put it in forward and current flows, minus a small voltage the diode keeps for itself.
The forward voltage
That toll is the forward voltage. For silicon diodes it’s commonly quoted as about 0.7 volts, but the real figure depends on how much current flows. A DC sweep in ngspice of a 1N4148 model, a common small-signal diode, gave:
| Forward current | Voltage across the diode |
|---|---|
| 1 µA | 0.27 V |
| 1 mA | 0.58 V |
| 10 mA | 0.69 V |
| 100 mA | 0.85 V |
A hundred-thousand-fold increase in current raised the voltage only from 0.27 to 0.85. That’s the exponential nature of a diode: a small voltage change makes a huge current change. The “0.7 volt” rule of thumb is a decent guess for the range of milliamps most circuits run at, and a poor one at very low or high currents.
What the datasheets say
Vishay’s 1N4148 datasheet, for “Small Signal Fast Switching Diodes,” gives a maximum forward voltage of 1 V at 10 mA. onsemi’s 1N4001 to 1N4007 datasheet for “Axial-Lead Glass Passivated Standard Recovery Rectifiers” lists 0.93 V typical and 1.1 V maximum at 1 amp and 25 °C. The simulated 0.69 V at 10 mA sits well inside Vishay’s maximum, as a typical part should.

Reading the ratings
Reverse voltage
Every diode has a limit to how much reverse voltage it can block before it breaks down. The 1N4148 is rated for 75 V. The 1N400x family spans a range; the onsemi table lists peak repetitive reverse voltages of “50 100 200 400 600 800 1000 V” across the seven parts, 50 V for the 1N4001 up to 1,000 V for the 1N4007. Since the parts are otherwise similar, the 1N4007 is the one many people keep in a parts drawer.
Current
The 1N4148’s continuous forward current rating is 300 mA. The 1N400x parts are rated for an average rectified current of 1.0 A, with a non-repetitive surge of 30 A for one cycle. The surge figure matters in power supplies, where the first moment after switch-on charges big capacitors with a heavy inrush.
Leakage
Reverse-biased diodes still let a tiny current through. onsemi’s table lists a maximum reverse current at rated voltage of 10 (with a typical of 0.05) in units the PDF text renders as microamps at 25 °C. Small, but it rises with temperature and matters in high-impedance or battery-powered circuits.
Speed
The 1N4148 has a reverse recovery time of 8 ns under Vishay’s test conditions. That’s how long it takes the diode to stop conducting when the voltage flips. The 1N400x parts are “standard recovery” rectifiers, made for 50 or 60 Hz mains, not for switching at high frequency. A slow rectifier in a fast switching circuit runs hot and wastes power.
The flyback problem
Inductors resist change
Relays, solenoids, motors and transformer windings are all inductors. OpenStax University Physics gives the governing relation as ε = −L dI/dt. The voltage across an inductor is proportional to how fast its current changes. Change the current slowly and the voltage is small. Try to stop it instantly and the equation asks for an enormous voltage.
What happens when a switch opens
A transistor driving a relay coil is a switch. When it turns off, it tries to stop the coil current in nanoseconds. The coil, carrying energy in its magnetic field, pushes back with whatever voltage it takes to keep the current flowing. That voltage appears across the transistor.
The simulation
The test circuit modeled a 100 mH coil with 120 Ω of winding resistance on a 12 V supply, switched to ground by an ideal switch with 10 MΩ off-resistance. Before switching off, the coil carried 99.9 mA.
With nothing else in the circuit, the switch voltage peaked at 491,108 volts. That absurd number comes from a perfect model with nowhere else for the current to go. Real coils have capacitance between their windings, which limits the spike. Adding 1 nF across the coil cut the peak to 1,010 V; 10 nF gave 328 V. Those match the simple estimate of the current times the square root of L over C: 1,000 V and 316 V. Either figure is far above what a small transistor can take. onsemi’s 2N3903/2N3904 datasheet, for one of the most common hobby NPN transistors, lists a collector-emitter rating of 40 V, with a continuous collector current of 200 mA. A 2N3904 switching this coil would be inside its current rating and about eight to twenty-five times past its voltage rating the instant it turned off.

How the flyback diode fixes it
Giving the current somewhere to go
A flyback diode, also called a freewheeling or snubber diode, sits across the coil, pointed so it’s reverse-biased during normal operation: cathode to the positive supply, anode to the transistor side. When the transistor turns off and the coil tries to keep its current flowing, the diode forward-biases and carries that current around in a loop through the coil itself.
Simulated result
With a diode added to the same circuit, the switch voltage peaked at 12.88 V: the 12 V supply plus one diode drop. The transistor never sees more than that.
The price: a slower release
The energy has to go somewhere, and with the diode it dissipates slowly in the coil’s own resistance. The coil current took about 10.9 milliseconds to fall to 10 mA with the diode, compared with essentially instantly without it. OpenStax gives the RL time constant as τ = L/R; here 100 mH over 120 Ω is about 0.83 ms per time constant, and with the diode’s drop added the decay takes several of them.
For a relay, a slower current decay means the contacts open a little later and a little more lazily. In most hobby projects that’s harmless. Where fast release matters, designers add a Zener diode or a resistor in series with the flyback diode, which allows a higher but still safe clamp voltage and a faster decay.
Choosing and placing the diode
Which part
For a small 5 V or 12 V relay coil, a 1N4148 is fast and handles the coil currents typical of small relays, comfortably inside its 300 mA continuous rating. For bigger coils, solenoids or motors drawing more, a 1N4007 with its 1 A rating is a common choice. The diode’s reverse rating only needs to exceed the supply voltage, since in normal operation it just sits reverse-biased across the coil.
Orientation
Backward, a flyback diode is a short circuit across the supply the moment the transistor turns on. The stripe, the cathode, goes toward the positive supply. Many relay modules sold for microcontroller projects include the diode already; checking for it before adding another avoids doubling up or, worse, adding one the wrong way.
Placement
The diode should sit as close to the coil as possible. A long wire between the coil and diode adds its own inductance and lets part of the spike through anyway. Soldered directly across the coil terminals is ideal.

Other everyday diode jobs
Reverse-polarity protection
A diode in series with a power input blocks current if the battery is put in backward, at the cost of one forward voltage drop on every milliamp the circuit draws. At 1 amp through a 1N4007, onsemi’s figures put that loss at roughly 0.93 to 1.1 volts, roughly a watt of heat.
Rectifying AC
Four diodes in a bridge turn alternating current into pulsing direct current, the first stage of countless power supplies. That’s the job the 1N400x family’s “standard recovery” design and 30 A surge rating are made for.
Combining signals
Two diodes feeding one point make a simple OR: either input can pull the point high, and neither can back-feed the other. It’s the logic behind diode-steered backup power, where a battery takes over automatically when a mains adapter is unplugged.
The two parts in this post
Both diodes discussed here are sold cheaply in bulk packs:
- Chanzon 100pcs 1N4148 Small Signal Fast Switching Diodes 200mA 100V DO-35: a 100-piece pack of the small glass signal diode used for flyback protection on small relay coils. See it on Amazon (affiliate link)
- BOJACK 1N4007 Rectifier Diode 1 A 1000 V DO-41 Axial 4007 1 amp 1000 Volt Electronic Silicon Diodes (Pack of 125): a 125-piece pack of the 1 A, 1,000 V rectifier suited to larger coils, reverse-polarity protection and mains rectifiers. See it on Amazon (affiliate link)
As an Amazon Associate I earn from qualifying purchases. A commission may be earned if you buy through this link, at no extra cost to you.
Sources
- Vishay, 1N4148 datasheet, “Small Signal Fast Switching Diodes”: https://www.vishay.com/docs/81857/1n4148.pdf
- onsemi, 1N4001–1N4007 datasheet, “Axial-Lead Glass Passivated Standard Recovery Rectifiers”: https://www.onsemi.com/pdf/datasheet/1n4001-d.pdf
- onsemi, 2N3903/2N3904 datasheet, “General Purpose Transistors NPN Silicon”: https://www.onsemi.com/pdf/datasheet/2n3903-d.pdf
- OpenStax, University Physics Volume 2, 14.2 “Self-Inductance and Inductors”: https://openstax.org/books/university-physics-volume-2/pages/14-2-self-inductance-and-inductors
- OpenStax, University Physics Volume 2, 14.4 “RL Circuits”: https://openstax.org/books/university-physics-volume-2/pages/14-4-rl-circuits
