DevTools Logo

Audio Waveform to SVG

Audio Waveform to SVG

Decode audio in your browser and turn it into a copyable SVG waveform. Nothing is uploaded.

Runs in your browser
Try an example

Waveform settings

Synthetic sine wave · 512 samples

Up to 64 MB. Source: Synthetic sine wave

SVG output

Each bar spans the minimum to maximum sample in its bin (peak envelope), so short peaks stay visible.

About

Upload browser-supported audio or use the built-in sine wave, inspect an inline SVG preview, and copy the generated SVG code.

Examples

Constant-one peak

Input
analyzeWaveform(new Float32Array([1, 1, 1, 1]), 2).blobs
Output
[{ peak: 1, max: 1, min: 1, rms: 1 }, { peak: 1, max: 1, min: 1, rms: 1 }]

A full-scale DC signal peaks at 1 in every bucket with unit RMS.

Bar vs line output

Input
generateWaveformPath(analysis, { style: "bar" }) vs { style: "line" }
Output
{ bar: "M x y L x y ...", line: "M x y L x y ..." (different strings) }

Bar emits per-blob verticals while line emits one envelope polyline.

About this tool

Audio Waveform to SVG turns samples into vector art: analyzeWaveform(samples, blobCount 64) buckets the input into min(blobCount, samples.length) blobs, each with start, end, min, max, rms, and peak, throwing on empty samples or a non-positive-integer blob count.

Paths come from generateWaveformPath(analysis, { width 800, height 240, style }): bar draws one vertical M/L segment per blob center, line draws the upper-envelope polyline, and area closes the upper plus reversed lower envelope with Z — coordinates format to 3 decimals around a center of height / 2 scaled by height / 2.

generateWaveformSvg(samples, { blobs, width, height, style, color #2563eb, strokeWidth }) wraps the path in an <svg> with viewBox, role img, and aria-label: bar uses stroke width 2 with no fill, line uses 3 with no fill, and area fills with the stroke color at 0.22 opacity.

How to use this tool

  1. Analyze samples

    Pass a Float32Array or number array with a blob count — 64 buckets by default, capped by sample length.

  2. Pick a style

    Choose bar for peaks, line for envelopes, or area for filled waveforms at 800×240 by default.

  3. Export SVG

    Call generateWaveformSvg for a complete <svg> string, or generateWaveformPath to embed the d attribute.

Use cases

Previewing takes

Render recorded buffers as inline SVG thumbnails in track lists.

Documenting audio

Embed deterministic waveform figures in reports and changelogs.

Styling players

Swap bar, line, and area styles to match player themes without re-analyzing.

Common mistakes

Mistake:Requesting more blobs than samples.

Fix:Blob count caps at samples.length — two samples with blobs 10 still yield two blobs.

Mistake:Passing an empty analysis to the path builder.

Fix:Zero-blob analysis throws — guard on blobs.length before calling generateWaveformPath.

Frequently asked questions

What does this tool do?

It analyzes samples with analyzeWaveform into min/max/rms/peak blobs, builds vector data with generateWaveformPath (bar, line, area), and wraps it in a complete <svg> via generateWaveformSvg.

How are blobs, styles, and sizes handled?

Blob count defaults to 64 and caps at samples.length; bar draws per-blob verticals, line draws the envelope polyline, area closes the filled shape; width/height default to 800×240 with bar stroke 2, line/area stroke 3, and color #2563eb.

Is my audio uploaded or stored?

No. Bucketing, path building, and SVG serialization run fully client-side.

Why did analysis throw, or blobs come back short?

Empty samples or zero-blob analysis throws cannot be empty and blob counts must be positive integers; short input caps blobs at the sample length, so two samples yield two blobs.

References & standards