Digital Filter Designer for IIR and FIR Filters
Operator: Abdulla Al Fahad. How tools are built and checked
A filter spec is a few numbers: where the passband ends, where the stopband starts, how much ripple you can live with and how much attenuation you need. Turning them into coefficients means choosing a family, finding the lowest order that meets the spec, mapping an analog prototype through a frequency transformation and the bilinear transform, and then splitting the result into biquads that a fixed-point or float32 filter can run without blowing up. Doing it by hand is a long afternoon; doing it twice for two sample rates is worse.
This page does that chain in the browser. Give it a sample rate and either the spec or an order and cutoff, and it returns second-order sections, the magnitude, phase and group delay, the pole-zero plot, the impulse and step response, and the same coefficients as CSV, a Python array, a MATLAB matrix or a CMSIS-DSP biquad table. It also rounds the coefficients to a Qm.n format and tells you whether the filter survives.
Key features
- IIR families: Butterworth, Chebyshev type I (passband ripple), Chebyshev type II (stopband ripple) and Bessel, each as lowpass, highpass, bandpass or bandstop
- Design from a spec (passband and stopband edges, maximum loss, minimum attenuation) with the lowest order that meets it, or from an order and cutoff
- Orders up to 24 for the Butterworth and Chebyshev families and up to 12 for Bessel, always as cascaded second-order sections rather than one high-order polynomial
- Windowed-sinc FIR with Kaiser (beta and length from the attenuation and transition width), Hamming, Hann, Blackman or rectangular windows, up to 4,001 taps
- Magnitude in dB, unwrapped phase, group delay in samples, pole-zero plot, impulse and step response, with a log frequency option
- Qm.n coefficient rounding with a stability check, a count of clipped coefficients and the change in response, plus export to CSV, Python, MATLAB and C
Filter families, band types and the coefficient formats
What you type is a sample rate in hertz and frequencies in hertz. For a lowpass or highpass filter there is one passband edge and one stopband edge; for bandpass and bandstop there are two of each, with the stopband edges outside the passband edges for a bandpass and inside them for a bandstop. Frequencies must lie above zero and below half the sample rate.
In order-and-cutoff mode the cutoff means different things for different families, and the page labels it. For Butterworth and Bessel it is the -3 dB point. For Chebyshev I it is the edge of the equiripple passband, and for Chebyshev II it is the edge where the stopband begins at the stated attenuation. Bessel filters are designed by order only, because their point is a flat group delay, not a stopband spec.
To filter a signal, give it one sample per row in a CSV or text file, or paste the numbers; if there is a header the first non-numeric row is skipped. The sample rate above is applied to the file, so the before-and-after spectra are labelled in hertz. WAV files are not read by this page.
How it works
The unit analog lowpass prototype comes from closed forms: Butterworth poles on the left half of the unit circle, Chebyshev poles on an ellipse set by the ripple, Chebyshev II poles as the inverses of those with zeros on the imaginary axis, and Bessel poles from the roots of the reverse Bessel polynomial, scaled so the gain is -3 dB at 1 rad/s. A lowpass-to-lowpass, highpass, bandpass or bandstop transformation moves it to the band you asked for.
The bilinear transform then maps the analog poles and zeros into the z-plane. Every edge is prewarped with 2·fs·tan(π·f/fs) first, so the digital filter has its edges exactly where you put them. Zeros and poles are paired into biquads: complex conjugates together, the poles nearest the unit circle last, and each pole pair with the nearest zero pair.
Order estimation uses the textbook closed forms. For Butterworth the order is log10((10^(Rs/10) − 1) / (10^(Rp/10) − 1)) divided by 2·log10 of the ratio of warped edges, and for Chebyshev it is the inverse hyperbolic cosine ratio of the same quantities, both rounded up. FIR design is the ideal sinc response times the window, scaled to unity gain in the passband.
Typical uses
- A firmware engineer needs a 4th-order Butterworth lowpass at 1 kHz for a 48 kHz audio path and wants a float32 biquad table: two sections come out, and the C export lists b0, b1, b2, -a1 and -a2 for each in the order the CMSIS-DSP df1 routine expects.
- A biomedical student removes 50 Hz mains hum from a 1 kHz ECG column with a bandstop between 48 and 52 Hz built from a 2nd-order prototype (two sections, 4th order overall): the notch is 68.5 dB deep at 50 Hz and costs 0.09 dB at 45 Hz.
- A controls engineer compares a 4th-order Bessel lowpass at 1 kHz and 8 kHz sampling: its group delay is 2.552 samples at DC and 2.875 samples at 900 Hz, a rise of 13%, where a 4th-order Butterworth at the same cutoff goes from 3.154 samples at DC to 5.361 at 900 Hz, a rise of 70%.
- A DSP course needs a 60 dB lowpass FIR with a 500 Hz transition at 8 kHz: the Kaiser formulas give beta 5.653 and 60 taps, a constant delay of 29.5 samples, and the worst stopband lobe is -60.4 dB.
Building one
- Pick IIR or FIR, enter the sample rate, and choose the band type.
- For IIR, choose a family and design from a spec or from an order and cutoff; for FIR, choose a window and set the cutoff and either the taps or an attenuation and transition width.
- Read the order, section count and stability in the result card, then check the magnitude, phase and group delay.
- Open the fixed-point card, set integer and fraction bits, and see whether the rounded filter is still stable and close to the exact one.
- Download the coefficients in the format your firmware or script takes, or load a sample column to see what the filter does to your own data.
Example
Lowpass at 8 kHz sampling: passband edge 1000 Hz with at most 1 dB loss, stopband edge 1500 Hz with at least 40 dB
Family Butterworth, then Chebyshev I, then Chebyshev II. Band lowpass. Sample rate 8000 Hz.Order and loss at the two edges
Butterworth: order 12 (6 sections), 1.000 dB at 1000 Hz, 43.97 dB at 1500 Hz
Chebyshev I: order 6 (3 sections), 1.000 dB at 1000 Hz, 43.22 dB at 1500 Hz
Chebyshev II: order 6 (3 sections), 0.505 dB at 1000 Hz, 40.00 dB at 1500 HzTips for best results
- Chebyshev II is the family to try first when you care about the stopband and want a flat passband; it reaches the same attenuation as Butterworth at half the order in the example above, with its ripple in the stopband where nobody sees it.
- Use the zero-phase option when you filter recorded data offline: it runs the filter forward and backward, squares the magnitude response and removes the delay, but it cannot be done on a live stream.
- Watch the group delay plot for band-edge peaks. The 6th-order Chebyshev I from the example delays 5.4 samples at DC and 25.9 samples at 990 Hz, just inside its passband edge, so a signal with content near the edge is smeared in time.
- For a narrow lowpass far below the sample rate, keep the sections as they are and use more fraction bits rather than a lower order. The poles crowd close to z = 1 and a coefficient step of 2^-14 can move them a long way.
Things to check before you rely on it
Elliptic (Cauer) filters and Parks-McClellan equiripple FIR design are not offered. When you need the narrowest transition for a given order, this page cannot give it, and Chebyshev II is the closest substitute.
The group delay of an IIR filter is measured from the exact coefficients, so it does not include the extra delay that a very coarse Qm.n rounding would add; check the fixed-point card before trusting it.
A FIR length is raised by one for highpass and bandstop filters, because an even length would force a zero at the Nyquist frequency. The note under the result says when that happened.
Common errors and how to fix them
- For a lowpass filter the stopband edge must be above the passband edge.
- Swap the two edges, or switch the band type to highpass, where the stopband is below the passband.
- This spec needs order 31; this tool designs up to order 24.
- Widen the transition band, accept less attenuation, or switch to Chebyshev, which needs far fewer sections for the same edges.
- Every edge must be above 0 and below half the sample rate.
- Check the sample rate first: an edge of 5 kHz at 8 kHz sampling is above the Nyquist frequency of 4 kHz.
Best practices
- Keep the gain spread evenly across the sections when the target is fixed point. It does not change the response, and it keeps every numerator well above one rounding step.
- Put the sections in the order the page gives them, with the poles nearest the unit circle last, so intermediate signals stay small.
- Check the response again after rounding to the format you will actually run, not only the exact design.
Why spreading the gain matters in fixed point
A 4th-order Butterworth lowpass at 1 kHz and 48 kHz sampling has an overall gain that is tiny at the input and large inside the loop. If the whole gain sits in the first section, its numerator is 1.555e-5, 3.110e-5, 1.555e-5. A Q1.14 coefficient has a step of 6.1e-5, so the first and third numerator terms round to zero and the middle one to a single step. The rounded filter has lost its zeros at z = -1, and the response changes by 2.913 dB where the exact gain is above -80 dB, and one of the other coefficients, 2.0, no longer fits.
With the gain spread evenly each numerator is about 0.0041, 0.0081, 0.0041, and the same Q1.14 rounding changes the response by 0.035 dB. The checkbox is on by default for IIR designs. Turn it off if you want the layout scipy.signal produces, with all the gain in the first section; both give the same frequency response to rounding error.
Reading the coefficient tables
Each row is one biquad, y = b0·x + b1·x[-1] + b2·x[-2] − a1·y[-1] − a2·y[-2], with a0 equal to 1. The Python and MATLAB exports list b0 b1 b2 a0 a1 a2 per row, which is the scipy sos layout and the MATLAB SOS matrix. The C export negates a1 and a2 and lists five numbers per stage, because CMSIS-DSP stores the feedback terms with the sign already flipped.
Frequently asked questions
How do I know the coefficients are right?
The digital magnitude responses were compared with the closed forms. For a Butterworth lowpass, |H|² equals 1 / (1 + (tan(ω/2) / tan(ωc/2))^(2n)), and the designs here agree with it to better than 1e-14 across 4,097 frequencies, for lowpass, highpass, bandpass and bandstop. Chebyshev I and II match their Chebyshev-polynomial forms to the same accuracy, and the Bessel poles match the roots of the reverse Bessel polynomials, for example -2.3222 and -1.8389 ± 1.7544j at order 3.
Why does the Butterworth need order 12 when Chebyshev needs 6?
A Butterworth response is maximally flat and pays for it with a gentle roll-off, so a transition from 1000 to 1500 Hz with 40 dB of attenuation takes 12 poles. The Chebyshev filters allow ripple in the passband or the stopband and use it to fall faster.
Does the filter I apply to my CSV change the sample rate?
No. The output has the same number of samples at the same rate. Only the frequency content changes, and the before-and-after spectra use Hann windows with 50% overlap so you can compare the two.
Can I get the exact section layout that scipy.signal produces?
Turn off the option that spreads the gain across the sections. The numbers then put all the gain in the first section, as sosfilt examples usually show. The frequency response is the same either way, so the choice only matters for fixed-point rounding and for comparing coefficient tables by eye.