📈

FFT Frequency Analyzer

This FFT frequency analyzer runs a configurable Fast Fourier Transform with selectable window functions (Rectangle, Hann, Hamming, Blackman, Blackman-Harris, Flat-top), magnitude & phase display, controllable bin resolution, and real-time peak detection. Educational and measurement-grade — every step is exposed.

100% browser-based — your microphone audio never leaves your device. No recording, no upload.
⏸ FROZEN
Magnitude spectrum · dBFS
Phase spectrum · radians · wrapped (−π to +π)
Bin width (Δf)
FFT size N
Window
Sample rate
Peak frequency
Peak magnitude

Top 5 spectral peaks

# Frequency Magnitude Phase Note
Start listening to detect peaks.

Controls

0 = raw frame-to-frame; higher = more stable but slower transient response.
Window characteristics:

Share or embed this tool

Free to use on your own website — WordPress, Wix, or any platform. Paste one line and it works instantly, resizing to fit.


About the FFT & Window Functions

The Fast Fourier Transform (FFT) is the workhorse of audio analysis: it takes a block of N time-domain samples and returns N/2 complex frequency-domain values, each representing the amplitude and phase of one frequency component. This online FFT runs entirely in the browser — no upload, no install — making it a practical browser FFT analyzer for anyone who needs to inspect a signal without installing desktop software. The big choice you make every time you run an FFT is the window function — how you shape the time-domain samples before the transform. Picking the right window is half the art of spectral analysis.

Why windows exist (spectral leakage)

The FFT mathematically assumes its input is one period of an infinitely-repeating signal. Real signals don't periodically align to the FFT block boundary, so the FFT sees a discontinuity at the wrap-around point — and that discontinuity smears each true frequency line into a wide skirt of false sidebands. This artifact is called spectral leakage. A window function multiplies the input by a smooth envelope that tapers to zero at the edges, eliminating the discontinuity at the cost of slightly widening the true frequency lobe.

The four key window properties

Every window trades off four characteristics:

  • Main-lobe width — how wide the peak around a single tone is. Narrower = better frequency resolution (you can separate close tones). Rectangle wins; Flat-top loses.
  • Side-lobe rejection — how much the leakage skirts are attenuated. Higher rejection = weak tones aren't hidden by strong ones nearby. Blackman-Harris wins; Rectangle loses.
  • Amplitude accuracy — how accurately the peak height matches the true tone amplitude. Flat-top is engineered for this; others can be off by 1.5 dB depending on where the tone lands relative to bin centers.
  • Coherent gain (CG) — the DC gain of the window. Used to normalize back to true amplitude.

When to use which window

  • Rectangle — never (unless you specifically want the rawest output for debugging or for a signal you know is periodic in the FFT block, e.g., FFT-synthesized tones).
  • Hann — default general-purpose choice. Reasonable side-lobe rejection (-31 dB), moderate main lobe. 90% of real-world FFT work uses Hann or Hamming.
  • Hamming — slightly better near-in side-lobe than Hann but worse far-out. Original telecom standard.
  • Blackman — sharper side-lobe rejection (-58 dB) at the cost of a wider main lobe. Use when weak tones near strong tones matter.
  • Blackman-Harris — extreme rejection (-92 dB) for highly contaminated spectra. Wide main lobe; only use if dynamic range matters more than resolution.
  • Flat-top — for amplitude measurement: peaks match the true tone level to within ~0.01 dB regardless of where the tone falls between bins. Very wide main lobe; useless for resolving close tones.

FFT size and bin resolution

The frequency resolution is Δf = sample_rate / N. At 48 kHz sample rate: N=4096 → 11.72 Hz/bin, N=16384 → 2.93 Hz/bin. Bigger N → finer resolution but more compute (and slower frame rate, since you need to wait longer for a full FFT block). For typical audio work, N=4096 to 8192 is the sweet spot. For very fine pitch work (instrument tuning, room modes below 100 Hz), use N=16384 or larger.

Magnitude and phase

Each FFT bin is a complex number; the magnitude tells you "how much energy is at this frequency", the phase tells you "what timing relationship" each frequency has relative to the start of the FFT block. For most audio work the magnitude is all that matters (since perception is mostly phase-insensitive). Phase shows up when comparing channels (stereo phase coherence), debugging filter group delay, or doing impulse-response measurement. The phase wraps to ±π by default; unwrapping can be useful for inspecting trends but is sensitive to noise.

Sample rate and Nyquist limit

The Web Audio API typically captures audio at 44,100 Hz or 48,000 Hz depending on your device's default. The highest frequency the FFT can represent is half the sample rate — the Nyquist frequency — so at 48 kHz you see up to 24 kHz. Frequencies above Nyquist fold back (alias) into the spectrum. Most browser microphones also apply high-pass filters and AGC (automatic gain control) in hardware, so absolute amplitude readings should be treated as relative, not calibrated. If you need a calibrated SPL measurement, use a purpose-built audio interface with a calibrated condenser microphone. For generating a test signal to analyze, you can create a reference tone with the tone generator and inspect its harmonic content here.

Detecting harmonic distortion

One practical use of a high-resolution FFT is measuring total harmonic distortion (THD) qualitatively: feed a pure sine tone (e.g. 1 kHz) from the tone generator into the device you want to test, capture the output with this analyzer, and look for peaks at 2 kHz, 3 kHz, 4 kHz … (the 2nd, 3rd, 4th harmonics). The relative height of those harmonic peaks compared to the fundamental tells you how much distortion is present. Use the Flat-top window for accurate amplitude comparison, and N ≥ 8192 for enough resolution to resolve harmonics at 1 kHz intervals. Note that your microphone and browser audio chain also add their own distortion, so results reflect the full signal path.

Frequently Asked Questions

How is this different from the Audio Spectrum Analyzer?
The Audio Spectrum Analyzer uses the Web Audio AnalyserNode, which forces a Blackman window internally and does not expose phase. This FFT Frequency Analyzer pulls raw time-domain samples from the microphone and runs its own radix-2 FFT in JavaScript — so window functions are user-selectable (Rectangle, Hann, Hamming, Blackman, Blackman-Harris, Flat-top), and both magnitude and phase are displayed. It is the more technical / educational tool.
Why is my single tone smeared across many bins?
Two reasons. (1) If the tone's frequency doesn't land exactly on a bin center, energy spreads into neighboring bins — this is "scalloping loss" and is fundamental to FFTs (mitigate it by using a wider window like Flat-top for amplitude or larger N for better bin alignment). (2) The window function itself has a finite main-lobe width — Hann's main lobe is 4 bins wide at -6 dB, Blackman's is 6, Flat-top's can be 10. The smear is the convolution of the true tone with the window's frequency response.
What's "coherent gain" and why is the spectrum normalized?
When you multiply the time-domain signal by a window w[n], the DC gain is reduced by a factor of (1/N) Σ w[n] — for Hann that's 0.5, for Blackman 0.42. To recover the true peak amplitude of a tone you divide the magnitude by this coherent gain. This calculator applies the correction automatically so a 0 dBFS tone reads as 0 dBFS regardless of which window you pick. Without correction, switching windows would shift every dB reading by a few dB just because of the window shape.
Why does the phase look like random noise most of the time?
Phase is only meaningful for bins where the magnitude is substantially above the noise floor. In bins with only background noise, the phase is essentially uniform on ±π. This is normal. Look at the phase plot only at frequencies where you see a clear magnitude peak — that's where the phase value carries useful information about the source signal's timing.
Is the FFT running on the GPU?
No — it's a JavaScript Cooley-Tukey radix-2 implementation running on the main thread, with precomputed twiddle factors. For N ≤ 8192 it comfortably hits real-time (~30–60 fps depending on hardware). For N = 16384 you may see 10–20 fps. A WebGPU or AudioWorklet-based implementation would be much faster but adds complexity; the current implementation is fast enough for typical audio inspection and keeps the code accessible.
Can I use this for FFT-based pitch detection?
Sort of — find the largest peak in the magnitude spectrum, optionally parabolic-interpolate around it for sub-bin precision. But for monophonic pitch detection, autocorrelation or YIN/CREPE give much better accuracy and immunity to harmonics. The Frequency Detector and Pitch Detector tools in the Frequency Detection category use dedicated pitch algorithms and will give cleaner results. This FFT tool is best for spectral analysis, not pitch tracking per se.
What's the difference between "wrapped" and "unwrapped" phase?
Phase is mathematically defined modulo 2π — it's only unique within a 2π range, conventionally −π to +π ("wrapped"). When the true phase progresses past those bounds, it jumps from +π to −π (or vice versa), making the plot look discontinuous. "Unwrapping" detects these jumps and adds 2π to keep the plot continuous, which is useful for inspecting smooth trends like a linear-phase filter's group delay. Unwrapping is sensitive to noise — small phase fluctuations near a wrap point can cause spurious 2π jumps in the unwrapped output.
What does the display smoothing slider actually do, and how is it different from averaging?
The smoothing slider controls an exponential moving average applied to the magnitude spectrum between display frames: new_display = α × old_display + (1 − α) × new_frame. At α = 0 you see every frame raw; at α = 0.8 the display reacts slowly. This is purely cosmetic — it does not change the FFT computation or improve frequency resolution. True spectral averaging (Welch's method, coherent averaging) would require accumulating multiple FFT frames mathematically and reduces noise floor while preserving stationary signal levels. This tool does not implement Welch averaging; the smoothing is only a visual aid to make rapidly changing spectra easier to read.
How do I measure harmonic distortion (THD) with this analyzer?
Feed a pure sine tone — for example 1 kHz from the tone generator — through the device or signal path you want to test, capture the output with this FFT analyzer, and look for peaks at 2 kHz, 3 kHz, 4 kHz (second, third, fourth harmonics). Use the Flat-top window for the most accurate amplitude comparison between the fundamental and the harmonics, and set N to 8192 or higher so that 1 kHz harmonics are cleanly separated. Keep in mind that your microphone, audio interface, and browser capture chain all add their own harmonic distortion, so the measurement reflects the full signal path from speaker to browser — not the device under test in isolation.
Does sample rate affect which frequencies I can see?
Yes. The highest frequency visible in any FFT is the Nyquist frequency — exactly half the sample rate. At 48 kHz (a common device default) the spectrum extends to 24 kHz, covering the full audible range. At 44,100 Hz it extends to 22,050 Hz. If your device defaults to 16 kHz (some narrow-band microphones), the usable spectrum only reaches 8 kHz. The sample rate shown in the stats row is what the Web Audio API reports for your device. You cannot override it in-browser without hardware or OS-level changes.