ConfigsJul 3, 2026·3 min read

Wavesurfer.js — Interactive Audio Waveform Visualization

A customizable audio waveform visualization library built on the Web Audio API and HTML5 Canvas that provides navigable, zoomable waveforms with plugin support.

Agent ready

Review-first install path

This asset needs a review step. The copied prompt tells the agent to dry-run, show the writes, then proceed only after confirmation.

Needs Confirmation · 66/100Policy: confirm
Agent surface
Any MCP/CLI agent
Kind
Skill
Install
Single
Trust
Trust: Established
Entrypoint
Wavesurfer.js Overview
Review-first command
npx -y tokrepo@latest install 1181f36c-7706-11f1-9bc6-00163e2b0d79 --target codex

Dry-run first, confirm the writes, then run this command.

Introduction

Wavesurfer.js renders navigable audio waveforms directly in the browser using the Web Audio API for decoding and HTML5 Canvas for drawing. It lets users see the shape of audio content, click to seek, zoom in for detail, and add region markers or annotations, making it popular in podcast editors, music apps, and transcription tools.

What Wavesurfer.js Does

  • Renders audio waveforms from any browser-supported audio format
  • Provides click-to-seek and drag-to-scroll navigation on the waveform
  • Supports zoom and responsive resizing of the waveform display
  • Offers a plugin system for regions, timeline, spectrogram, and minimap
  • Handles pre-computed peaks data for server-rendered waveforms

Architecture Overview

Wavesurfer.js decodes audio using the Web Audio API's AudioContext.decodeAudioData method, extracting PCM sample data for waveform rendering. The peaks are downsampled to match the canvas width and drawn as vertical bars or continuous lines. Playback progress is tracked via requestAnimationFrame, updating the progress overlay in real time. The plugin architecture uses an event emitter pattern, allowing extensions like Regions and Timeline to hook into lifecycle events without modifying the core.

Self-Hosting & Configuration

  • Install via npm and import, or load from a CDN
  • Set container to a CSS selector or DOM element for the waveform target
  • Customize colors with waveColor, progressColor, and cursorColor
  • Pass peaks and duration to skip client-side audio decoding for large files
  • Use the Regions plugin for annotating and looping specific audio segments

Key Features

  • Real-time waveform rendering with Web Audio API decoding
  • Interactive seeking, scrolling, and zooming
  • Region markers for annotation, looping, and segment editing
  • Spectrogram and minimap visualization plugins
  • Server-side peak pre-computation for instant rendering of large files

Comparison with Similar Tools

  • Peaks.js — BBC-maintained with similar features; Wavesurfer.js has broader plugin ecosystem
  • Howler.js — audio playback library without visualization; Wavesurfer.js combines both
  • Tone.js — synthesis and effects framework; Wavesurfer.js focuses on visualization and playback
  • Amplitude.js — playlist management with UI; Wavesurfer.js provides detailed waveform control

FAQ

Q: Can I render waveforms without playing the audio? A: Yes. Pass pre-computed peaks data and the waveform renders instantly without decoding the audio file.

Q: Does it support live audio or streaming? A: Wavesurfer.js supports the MediaElement backend for streaming audio and live microphone input via plugins.

Q: How do I add loop regions? A: Import the Regions plugin, call wavesurfer.registerPlugin(RegionsPlugin.create()), then add regions with start and end times.

Q: What audio formats are supported? A: Any format the browser's Web Audio API can decode, typically MP3, WAV, OGG, FLAC, and AAC.

Sources

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets