Audio Frequency Equalizer Bars — Free HTML CSS JS Snippet

Audio Frequency Equalizer Bars · Charts · Plain HTML, CSS & JS · Live preview

What's included

Features

Live Web Audio spectrum analysis driving a real equalizer bar chart
Four synthesized oscillators forming a chord for visible spectrum variation
AnalyserNode.getByteFrequencyData() sampled into a fixed 48-bar display
Per-bar vertical gradient fill for a polished, classic equalizer look
requestAnimationFrame render loop synced to the actual audio signal
Complete oscillator array cleanup and AudioContext close on Stop
No external audio files or visualization libraries required
Idle flat-bar state shown before any interaction

About this UI Snippet

Audio Frequency Equalizer Bars — Live Spectrum Visualizer With Web Audio API

Screenshot of the Audio Frequency Equalizer Bars snippet rendered live

This snippet recreates the classic music-player equalizer bar visualization using nothing but the Web Audio API and a canvas — no audio files and no external visualization library. Pressing Play starts several synthesized oscillators at once and renders their combined frequency spectrum as a row of animated vertical bars.

A small chord of oscillators

Rather than a single tone, startPlayback() creates four OscillatorNode instances tuned to different frequencies (a simple chord), each connected into a shared GainNode for volume control. Feeding multiple frequencies into the analyser gives the bar chart visible variation across the spectrum instead of a single narrow spike, which is what makes it read as a genuine equalizer rather than a single pulsing bar.

Frequency-domain analysis

The AnalyserNode is configured with a small fftSize of 256, producing 128 frequency bins from analyser.getByteFrequencyData(). The draw loop samples a subset of those bins (one every few indices) to populate a fixed number of bars, so the bar count on screen stays constant regardless of the underlying FFT resolution.

Rendering with gradient bars

Each bar's height is proportional to its frequency bin's magnitude (0-255, normalized to the canvas height), redrawn every requestAnimationFrame tick. Each bar gets its own vertical gradient from pink to orange, giving the classic equalizer look while still being driven entirely by live audio data rather than a canned animation.

Full cleanup on Stop

Stop cancels the animation frame, stops and disconnects every oscillator in the oscillators array, disconnects the gain and analyser nodes, and closes the AudioContext — leaving no lingering audio processing or animation loop running after the user is done.

Build with AI

Build, Understand, Optimize, and Extend It With AI

Hand this snippet's HTML, CSS, and JavaScript to an AI coding assistant like Claude and ask it to adapt "Audio Frequency Equalizer Bars" to your project — restyle it to match your design system, wire it up to real data instead of the static example, or port it to the framework you're building in.

Prompt to recreate it

Copy this into your AI assistant of choice to build the effect from scratch, or as a jumping-off point for your own variant:

text
Build a charts component called "Audio Frequency Equalizer Bars" using plain HTML, CSS, and vanilla JavaScript — no framework, no build step.

Requirements:
- Match the structure and behavior of the "Audio Frequency Equalizer Bars" snippet from the UI Snippets Library.
- Keep the markup semantic and the styling self-contained (no external dependencies beyond what the original snippet uses).
- Keep the JavaScript vanilla, with no framework runtime required.
- Make it easy to restyle via CSS custom properties or class overrides so it can be dropped into a real project.

Want to tighten it up first? Run this prompt through the AI Prompt Studio to score it across 8 quality dimensions, catch anti-patterns, and tune the wording for Claude, ChatGPT, or Gemini before you paste it in.

Source Code

<div class="eq-card">
  <div class="eq-head">
    <div>
      <span class="eq-eyebrow">Spectrum</span>
      <h2>Frequency Equalizer</h2>
    </div>
    <span class="eq-status" id="eqStatus">Idle</span>
  </div>

  <canvas class="eq-canvas" id="eqCanvas" width="600" height="180"></canvas>

  <div class="eq-controls">
    <button class="eq-btn eq-btn-play" id="eqPlayBtn">
      <svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor"><path d="M8 5v14l11-7z"/></svg>
      Play
    </button>
    <button class="eq-btn eq-btn-stop" id="eqStopBtn" disabled>
      <svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor"><path d="M6 6h12v12H6z"/></svg>
      Stop
    </button>
  </div>
</div>

Step by step

How to Use

  1. 1
    Load the snippetClick "Audio Frequency Equalizer Bars" in the sidebar to load its HTML, CSS, and JS into the editor panels. The preview updates instantly.
  2. 2
    Edit the codeModify any panel — HTML, CSS, or JS. The preview refreshes as you type. Use Reset in each panel header to restore the original.
  3. 3
    Preview on devicesClick the Mobile (375px), Tablet (768px), or Desktop buttons in the preview header to check responsiveness.
  4. 4
    Export in your formatClick "HTML" to download a standalone file, "JSX" for a React component, "Tailwind" for a React + Tailwind CSS component, "Tailwind HTML" for a standalone HTML file with Tailwind CDN, "Vue" for a Vue 3 SFC with <template>/<script setup>/<style scoped>, or "Angular" for a standalone Angular .component.ts file. "Copy all" copies the full code to clipboard.
  5. 5
    Save your versionClick "Save as", type a name, and press Enter. Your snippet saves to IndexedDB and appears in the Saved tab.

Real-world uses

Common Use Cases

Music and podcast players
The signature equalizer visualization used across most audio player UIs.
Audio product landing pages
A lively visual centerpiece to demonstrate sound features without shipping audio assets.
Web Audio API spectrum tutorials
Demonstrates getByteFrequencyData() with a chord of oscillators instead of a single tone.
DJ or synth tool prototypes
Reusable as a live spectrum monitor for any generated or mixed audio signal.

Got questions?

Frequently Asked Questions

A single sine tone only lights up one narrow frequency bin, which looks static. Playing a small chord of four different frequencies spreads energy across the spectrum so the bar chart shows visible, varied movement like a real equalizer.

Yes — replace the oscillator setup with an HTMLMediaElement source via audioCtx.createMediaElementSource(audioEl) and connect that into the same analyser chain; the drawing code needs no changes.

The draw loop computes a step size (dataArray.length divided by the desired bar count) and samples one frequency bin per bar at that interval, so barCount stays fixed even if fftSize is changed.