Advertisement
🔊

Base64 to Audio Decoder

Decode a Base64-encoded audio string into an MP3, WAV, OGG, or other audio file you can play and download. Auto-detects format from data URI prefix or file signature. 100% browser-only — audio never uploads.

Advertisement

Decoding Base64 Audio in 2026

Most modern Text-to-Speech APIs return audio as a Base64 string inside a JSON payload — it's the simplest way to deliver binary content over an HTTP API that demands JSON. To play that audio in a browser or save it to a file, you need to decode the Base64 back to raw bytes and either pipe those bytes to an <audio> element via a Blob URL, or write them to disk.

The challenge is usually format detection. APIs may return MP3, WAV, OGG, M4A, or even raw PCM depending on the model and the requested encoding. The data may or may not include a data URI prefix (data:audio/mp3;base64,…). And many copy-paste scenarios introduce stray whitespace, newlines, or surrounding quotes that break naive parsers.

What the Tool Does

  1. Strips noise — data URI prefix, whitespace, newlines, surrounding quotes — to recover clean Base64.
  2. Decodes the Base64 to a Uint8Array.
  3. Detects the format by checking the first few bytes against known magic numbers: ID3 or FF FB for MP3, RIFF…WAVE for WAV, OggS for OGG, 1A 45 DF A3 for WebM, fLaC for FLAC.
  4. Wraps in a Blob with the right MIME type and creates an object URL.
  5. Plays + downloads via the browser's audio element and a download link.

Decoding Base64 Audio in Code

// Browser
const b64 = "...";
const bytes = Uint8Array.from(atob(b64), c => c.charCodeAt(0));
const blob = new Blob([bytes], { type: 'audio/mpeg' });
const url = URL.createObjectURL(blob);
audio.src = url;     // play in <audio>
// Or to download:
const a = document.createElement('a');
a.href = url;
a.download = 'output.mp3';
a.click();

// Node.js
import { writeFileSync } from 'fs';
writeFileSync('out.mp3', Buffer.from(b64, 'base64'));

// Python
import base64
with open('out.mp3', 'wb') as f:
    f.write(base64.b64decode(b64_string))

The reverse direction (audio file → Base64) is in our Audio to Base64 tool. For non-audio Base64, use the general-purpose Base64 Decoder.

How to Use

  1. Paste your Base64 — with or without 'data:audio/...;base64,' prefix.
  2. Pick a format — leave on Auto unless detection fails.
  3. Click Decode — the audio plays in the browser and a download link appears.
  4. Verify by playing — if the player shows an error, the Base64 is corrupt or the format is misdetected; try selecting the format manually.

Frequently Asked Questions

When do I need to decode Base64 audio?

Most often when working with Text-to-Speech APIs (Google Cloud TTS, Amazon Polly, ElevenLabs, OpenAI TTS) — they typically return synthesized audio as a Base64-encoded string in JSON, which you then decode and either play or save as a file. Also when debugging audio in API responses, when handling Web Speech API output, or when extracting audio from data: URIs in HTML.

What formats are supported?

Any browser-playable audio format works: MP3 (audio/mpeg), WAV (audio/wav), OGG (audio/ogg), WebM (audio/webm), M4A/AAC (audio/mp4), FLAC (audio/flac). The tool auto-detects format from the data URI prefix (e.g., 'data:audio/mp3;base64,…') or from the file's magic bytes. If detection fails, you can pick the format manually.

Can I paste with or without the 'data:audio/...;base64,' prefix?

Both work. The parser strips the data URI prefix automatically before decoding. Whitespace, newlines, and surrounding quotes are also stripped. So you can paste an entire JSON-extracted value or just the raw Base64 — both decode correctly.

Is there a size limit?

Browsers handle audio up to a few hundred megabytes comfortably. The Base64 representation is about 33% larger than the binary, so a 100MB MP3 is ~133MB of Base64 text. For very large clips, the page may stutter while parsing — consider chunked processing or a desktop tool.

How do I decode Base64 audio in code?

In JavaScript: const blob = new Blob([Uint8Array.from(atob(b64), c => c.charCodeAt(0))], {type:'audio/mp3'}); const url = URL.createObjectURL(blob); audio.src = url. In Node.js: Buffer.from(b64, 'base64') gives the raw bytes — write to a file or stream to a player. In Python: base64.b64decode(b64_string) returns bytes; write with open('out.mp3','wb').write(bytes).

Comments

No comments yet. Be the first!