Parts
LM358 vs LM393: which one for your threshold circuit, and what breaks when you swap them
By Bulan Sarkar
The LM358 is a dual op amp. The LM393 is a dual comparator. They share the same pin order: outputs on 1 and 7, inputs on 2-3 and 5-6, ground on 4, supply on 8. Both run from a single supply and both accept inputs down to ground. That is why people mix them up, and why one often ends up in the other's socket.
They behave differently in four ways:
- The LM358 drives its output high and low. The LM393 output can only pull down, so it needs a pull-up resistor to go high. That resistor can go to any voltage up to 36 V, so shifting a 5 V signal down to 3.3 V takes one resistor.
- As a comparator the LM393 is faster. TI gives it a typical response of 1.3 µs. The LM358 slews at 0.3 V/µs, so a 3.5 V swing on a 5 V supply takes about 12 µs.
- The LM358 amplifies, buffers and filters. TI says the LM393 "operates solely as a voltage comparator", so it cannot be an amplifier.
- The LM393 runs from 2 V, the LM358 from 3 V. Both are rated to 30 V.
Rule of thumb: if the output only ever needs to be high or low, use the LM393 and fit the pull-up. If the output is an analog voltage (a gain stage, a buffer, a filter), use the LM358. An LM358 used as a comparator works for slow signals like a thermostat or a battery alarm. It is the wrong choice for anything that switches more often than a few thousand times a second.
Pinout by package
Top view, notch up: pin 1 is top left. Two op amps; V− (or ground) on 4, V+ on 8.
Source: Texas Instruments LMx58, LM2904 Industry-Standard Dual Operational Amplifiers (SLOS068AB), p. 3 (Figure 4-1 and Table 4-1, 8-pin packages: OUT1 1, IN1− 2, IN1+ 3, V− 4, IN2+ 5, IN2− 6, OUT2 7, V+ 8)
Top view, notch up. The same pin order as the LM358; the outputs on 1 and 7 can only pull down.
Source: Texas Instruments LM393B, LM2903B, LM193, LM293, LM393 and LM2903 Dual Comparators (SLCS005AH), p. 3 (Figure 4-1 and Table 4-1, D, DGK, JG, P, PS, DDF and PW packages: 1OUT 1, 1IN− 2, 1IN+ 3, GND 4, 2IN+ 5, 2IN− 6, 2OUT 7, VCC 8)
Same socket, different output
Both chips put the same signal on the same pin, so the boards look identical. The difference sits behind pins 1 and 7. The LM358 has two output transistors, one that pulls up and one that pulls down. The LM393 has only the bottom one: an NPN that sinks current when IN− is above IN+ and lets go otherwise.
The logic sense is the same on both: the output goes low when IN− is above IN+. What changes is what "high" means. On the LM358 it is a driven voltage, at least 3.5 V on a 5 V supply. On the LM393 it is whatever the pull-up resistor connects to.
Side by side
| Parameter | LM358PDIP-8 | LM393PDIP-8 |
|---|---|---|
| What it is | dual operational amplifier | dual voltage comparator |
| Supply, recommended VS | 3 to 30 V | 2 to 30 V |
| Supply, absolute maximum VS | 32 V | 36 V |
| Output stage | push-pull: drives high and low | open collector: pulls low only, a pull-up sets the high level |
| ESD rating, human-body model | ±500 V (LM358B: ±2000 V) | ±2000 V |
| Operating temperature TA | 0 to 70 °C (LM2904: −40 to 125 °C) | 0 to 70 °C (LM2903: −40 to 125 °C) |
| Parameter | LM358PDIP-8 | LM393PDIP-8 |
|---|---|---|
| Output high, 5 V supply VOH | at least 3.5 V (within 1.5 V of V+, load 2 kΩ or more) | set by the pull-up rail, up to 36 V |
| Output low VOL | 5 typ / 20 max mV above V− (light load) | 130 typ / 400 max mV at 4 mA sink |
| Output current | source 20 mA min, sink 10 mA min (15 V supply) | sink 6 mA min at 1.5 V; 20 mA absolute max |
| Input range VICR | 0 V to V+ − 1.5 V at 25 °C (V+ − 2 V over 0 to 70 °C) | 0 V to VCC − 1.5 V at 25 °C (VCC − 2 V over 0 to 70 °C) |
| Input offset voltage VOS | 3 typ / 7 max mV at 25 °C; 9 mV max, 0 to 70 °C | 2 typ / 5 max mV at 25 °C; 9 mV max, 0 to 70 °C |
| Input bias current, 25 °C IB | 20 typ / 250 max nA (500 nA, 0 to 70 °C) | 25 typ / 250 max nA (400 nA, 0 to 70 °C) |
| Speed | 0.7 MHz gain bandwidth; 0.3 V/µs slew rate | 1.3 µs typ response (5 mV overdrive); 0.3 µs with a TTL-level step |
| Supply current, 5 V, no load IQ | 350 typ / 600 max µA per amplifier | 0.45 typ / 1 max mA for both comparators |
The two speed rows measure different things, so don't compare 0.3 V/µs with 1.3 µs directly. Example 1 turns them into the same unit. The LM393 column is TI's original LM393, not the newer LM393B, which has its own tables in the same datasheet.
The swap trap: the pins match, the outputs don't
Because the pinouts line up, an LM393 fits an LM358 socket and the reverse. The circuit around it decides whether it works.
An LM393 in an LM358 circuit
- Any amplifier, buffer or filter stops working. The LM393 has no linear output and no way to drive high.
- An LM358 wired as a comparator with its load to ground (an LED from the output to ground, or a logic input with a pull-down) goes dark. The LM393 output never drives high on its own. Add a pull-up resistor from each output to the rail the load expects.
- The logic sense stays the same. Both outputs go low when IN− is above IN+.
An LM358 in an LM393 circuit
- The pull-up resistor stays on the board. The LM358 can drive against it, so this mostly still works, but the output's high level is now set by the LM358 (at least 3.5 V on a 5 V supply), not by the pull-up rail.
- If the LM393's pull-ups went to a different rail (for example a 5 V comparator feeding a 3.3 V microcontroller), the LM358 now drives its own high level into that pin. See example 2.
- Two LM393 outputs tied together (a wired-AND, which TI's datasheet describes) become two LM358 outputs fighting each other. TI warns that an LM358 output shorted to the supply can overheat and fail. Don't tie LM358 outputs together.
- Edges get about ten times slower. See example 1.
Worked examples
1. How fast does the output switch?
You want a clean digital edge from a slowly moving sensor signal, on a 5 V supply.
- LM358 used as a comparator: the output has to travel from near 0 V to at least 3.5 V. At the typical slew rate of 0.3 V/µs that takes 3.5 ÷ 0.3 = 11.7 µs, and the same again on the way down. That figure comes from a unity-gain test. TI does not say how fast the LM358 recovers when it runs open-loop and saturated, so treat 12 µs as a floor, not a promise.
- LM393: TI gives 1.3 µs typical from the input step to the output crossing 1.4 V, with only 5 mV of overdrive. With a TTL-sized input step it is 0.3 µs. The rising edge also depends on the pull-up: TI gives the rise time as about RPULLUP × CL, so 4.7 kΩ and 15 pF give 71 ns.
Say you square up a 40 kHz signal (an example input; a 40 kHz ultrasonic receiver is a common hobby case). Each half-cycle lasts 12.5 µs. The LM358 needs about 11.7 µs just to move its output from one level to the other, so the "square" wave is mostly ramps. The LM393's 1.3 µs response fits easily. For a signal of a few hundred hertz, or a thermostat that switches once a minute, the LM358 is fast enough.
2. A 5 V sensor stage feeding a 3.3 V microcontroller
The sensor and the comparator run from 5 V. The output goes to a GPIO pin on a 3.3 V board.
- LM393 with a 10 kΩ pull-up to the 3.3 V rail: the output high is 3.3 V. TI's high-level leakage is 50 nA maximum, which drops 50 nA × 10 kΩ = 0.5 mV across the resistor. When the output is low it sinks 3.3 V ÷ 10 kΩ = 0.33 mA, well inside TI's 1 µA to 4 mA pull-up range, so the low level stays under the 400 mV that TI gives at 4 mA.
- LM358 on the same 5 V supply: the output goes at least as high as 3.5 V with a 2 kΩ or lighter load, and TI gives no upper limit short of the rail. That is above the 3.3 V rail. Check your microcontroller's datasheet for its input limit, then either add a divider on the output or switch to the LM393.
The LM393 does this with one resistor, which is the main reason to pick a comparator over an op amp for a logic output.
3. An indicator LED
You want an LED that lights when the input crosses the threshold, on a 5 V supply. For this example take a red LED with a 2.0 V forward drop (read yours from its datasheet).
LM393: connect the LED and its resistor from 5 V down to the output. The LED lights when the output pulls low, which is when IN− is above IN+. Aim for 4 mA, the current at which TI gives the low-level output voltage (130 mV typical, 400 mV maximum):
- Resistor: (5 − 2.0 − 0.4) ÷ 0.004 = 650 Ω. The next E24 value up is 680 Ω.
- Current with 680 Ω: 3.82 mA worst case, about 4.22 mA typical.
In this connection the LED and its resistor are the only pull-up on that output. If the same output also feeds a logic input, add a pull-up resistor anyway, so the logic sees a defined high when the LED is off.
LM358: either connection works, because the output drives both ways. With the LED from the output to ground it lights while the output is high. TI gives the LM358's source current as at least 20 mA, but only at a 15 V supply. At 5 V the output high is lower, at least 3.5 V, so work the resistor out from 3.5 V, not 5 V: (3.5 − 2.0) ÷ 0.004 = 375 Ω, next E24 value 390 Ω. Measure the high level on your board if you need a precise current. The LED resistor calculator does the same sum for other LEDs.
4. A low-battery alarm for a 12 V battery
A 5 V regulator runs the circuit. You want the alarm to trip when a 12 V lead-acid battery falls to about 11.5 V. The battery numbers here are example inputs; take your own from the battery maker.
The input range sets the divider. On a 5 V supply both chips accept 0 V to 3.5 V at 25 °C, but only up to 3.0 V across 0 to 70 °C. Plan for 3.0 V. If the battery can reach 15 V while charging, the divider must keep 15 V under 3.0 V:
- Battery divider 43 kΩ over 10 kΩ: ratio 10 ÷ 53 = 0.189. At 11.5 V the tap sits at 2.17 V; at 15 V it reaches 2.83 V. Both are inside the range.
- Reference divider 13 kΩ over 10 kΩ from the 5 V rail: 5 × 10 ÷ 23 = 2.17 V. The alarm trips at 2.174 ÷ 0.189 = 11.52 V. The trip point moves with the 5 V rail, so it can be no better than the regulator's accuracy. The voltage divider calculator works out other ratios.
Accuracy, worst case over 0 to 70 °C, referred back to the battery:
- Offset: both chips are 9 mV maximum. 9 mV ÷ 0.189 = 48 mV at the battery.
- Bias current through the divider's 8.11 kΩ source resistance (43 kΩ in parallel with 10 kΩ): the LM393's 400 nA gives 3.2 mV, the LM358's 500 nA gives 4.1 mV. Both are small next to the offset.
So for a slow DC threshold like this the LM358 is as accurate as the LM393. Pick by the output you need: a pull-up to a logic rail favors the LM393; driving a buzzer transistor's base from a push-pull output favors the LM358. Either way, a battery voltage that drifts slowly through the threshold will make the output chatter. The LM393 page shows how to add hysteresis with one feedback resistor.
What if the divider had been 36 kΩ over 10 kΩ, putting 11.5 V at 2.50 V? At 14.4 V the tap reaches 3.13 V, just above the 3.0 V limit. TI's LM393 sheet says the output stays correct as long as one input is inside the range, and the 2.50 V reference is. The LM358 sheet makes no such statement, so on an LM358 keep both inputs inside the range.
5. Current draw on a battery
Both chips idle on very little current, so the choice rarely matters for battery life. At 5 V with no load:
- LM358: 350 µA typical, 600 µA maximum per amplifier, so 0.7 mA typical and 1.2 mA maximum for the pair.
- LM393: 0.45 mA typical, 1 mA maximum for both comparators together.
The LM393's pull-up resistor draws current whenever the output is low: 5 V ÷ 10 kΩ = 0.5 mA per output. If the output sits low most of the time, that resistor costs more than the chip. Use a larger pull-up (100 kΩ draws 50 µA) when speed doesn't matter, since the rise time grows with RPULLUP × CL.
Worked example in numbers
- LM358 edge on 5 V
- 11.7 µs
- LM393 response, typ
- 1.3 µs
- Alarm trip point
- 11.52 V
- LED resistor, LM393
- 680 Ω
Swapping one for another
| Part | Pins | Verdict |
|---|---|---|
| LM393 for an LM358 | same pinout | Only where the LM358 is used as a comparator, and only with a pull-up on each output that has to go high. Amplifiers, buffers and filters stop working.Texas Instruments LM393B, LM2903B, LM193, LM293, LM393 and LM2903 Dual Comparators (SLCS005AH), p. 17 |
| LM358 for an LM393 | same pinout | Works for slow thresholds if no outputs are tied together and the next stage accepts the LM358 high level. Edges are about ten times slower.Texas Instruments LMx58, LM2904 Industry-Standard Dual Operational Amplifiers (SLOS068AB), p. 10; Texas Instruments LMx58, LM2904 Industry-Standard Dual Operational Amplifiers (SLOS068AB), p. 4 |
| LM393B for an LM393 | same pinout | TI calls it a drop-in replacement. It runs from 2 to 36 V.Texas Instruments LM393B, LM2903B, LM193, LM293, LM393 and LM2903 Dual Comparators (SLCS005AH), p. 1 |
Which one fits your job
- Choose the LM393 for threshold detectors with a logic output, level shifting to 3.3 V or up to 12 V, zero-crossing and pulse squaring, wired-AND alarm lines, and anything that must switch faster than about 10 µs.
- Choose the LM358 for amplifiers, buffers, active filters, current-sense stages and integrators, and for slow comparators where you want one chip to do both a gain stage and a threshold. For other op amps, see LM358 vs 741 vs TL072.
- To swap an LM358 comparator for an LM393, add a pull-up on each output that needs to go high, and check the output polarity your load expects.
- To swap an LM393 for an LM358, check that the circuit doesn't tie outputs together, that the pull-up rail is the same as the supply (or that the next stage tolerates the LM358's high level), and that the slower edges are acceptable.
- The newer TI B versions keep the same pins. TI says the LM393B is a drop-in replacement for the LM393; the LM358B is faster (1.2 MHz, 0.5 V/µs) and runs to 36 V.
Tips and checks
- Keep inputs from going more than 0.3 V below ground. TI warns that the LM393's output can then be wrong and excess input current can flow.
- Bypass the supply at pin 8. TI's LM358 sheet asks for a 0.1 µF ceramic close to the pin; the LM393 sheet asks for a bypass capacitor and warns against running output traces parallel to the inverting inputs.
- The LM393's output can be shorted to ground indefinitely. A short to the supply can destroy either chip.
- The LM358 is rated for ±500 V human-body ESD, the LM393 for ±2000 V. Handle the LM358 with more care.
What we'd do
For any output that only has to be high or low we'd fit an LM393 with a 10 kΩ pull-up to the rail the next stage runs on. We'd keep the LM358 for gain stages and filters, and use its spare half as a comparator only when the signal is slow and the output can sit at the LM358's own high level.
Questions people ask
Can I use an LM358 as a comparator?
Yes, for slow signals. It works open-loop, drives both high and low, and its offset is as good as the LM393's for DC thresholds. Its 0.3 V/µs slew rate means about 12 µs per edge on a 5 V supply, so it is too slow for signals above a few kilohertz.
Can I use an LM393 as an op amp?
No. TI says it operates only as a voltage comparator. Its output can only pull down, so it cannot hold a linear output voltage.
Why does my LM393 output stay low or read 0 V?
Usually there is no pull-up resistor. The output is open collector and only pulls down. Add a resistor from the output to the logic rail. TI's design range is 1 µA to 4 mA of pull-up current; 10 kΩ to 5 V (0.5 mA) is a common choice.
Are the LM358 and LM393 pin-compatible?
The pin order is the same in the 8-pin packages: outputs on pins 1 and 7, inputs on 2-3 and 5-6, ground on 4, supply on 8. The output stages are different, so the circuit around the chip has to suit the one you fit.
Which is more accurate for a voltage threshold?
About the same. Over 0 to 70 °C both have a maximum input offset of 9 mV, and both have 250 nA maximum input bias current at 25 °C.
Where to go next
Each chip has its own page with packages, ratings and an application circuit: LM358 and LM393 (which also covers hysteresis and the quad LM339). The comparator lesson explains thresholds and hysteresis from the inside, and op-amp limitations covers slew rate and input range. If you are building a timer rather than a threshold, the NE555 is the part to read next.
One email a month from the bench
New circuits, lessons, part guides and calculators, on the first Sunday of each month.
Used in these lessons
Lessons that go deeper
Datasheets this page was checked against
- Texas Instruments, LM393B, LM2903B, LM193, LM293, LM393 and LM2903 Dual Comparators (SLCS005AH) (SLCS005AH, October 1979, revised April 2025)
- Texas Instruments, LMx58, LM2904 Industry-Standard Dual Operational Amplifiers (SLOS068AB) (SLOS068AB, June 1976, revised October 2024)
Makers revise datasheets. If the copy you download has a newer revision and a number here disagrees with it, the datasheet wins, and we would like to hear about it.