Audio to Base64 Converter

Encode MP3, WAV, OGG and other sound files as Base64 for HTML, JavaScript or speech API requests. Play the file in the built-in player, then copy the raw string or a data URI.

Runs entirely in your browser. Nothing is uploaded.

How to use

  1. Drop an audio file onto the upload area or click to choose one: MP3, WAV, OGG, M4A, FLAC or another format.
  2. Play it in the preview player to check that it is the right sound.
  3. Choose a data URI for an HTML audio element, or raw Base64 for an API request.
  4. Copy the result or download it as a .txt file.

Playing Base64 audio in a web page

A data URI with an audio MIME type works anywhere a browser expects an audio URL:

<audio controls src="data:audio/mpeg;base64,..."></audio>

// JavaScript: play a short sound when a button is clicked
const click = new Audio('data:audio/wav;base64,...');
button.addEventListener('click', () => click.play());

Browsers usually block sound from starting before the visitor has interacted with the page, so call play() from a click or key handler rather than on page load.

Good uses for Base64 audio

  • Short interface sounds. Clicks, notification chimes and error beeps of a few kilobytes can live inside your JavaScript bundle, so they play instantly with no extra request.
  • Offline and single-file apps. Games, kiosks, e-learning packages and HTML reports that must work from one file without a server can carry their sounds inline.
  • Speech-to-text APIs. Many cloud speech recognition services accept a short recording as a Base64 field, often called content or audio, in a JSON request. They usually expect a particular format, sample rate and channel count. This tool encodes the file exactly as it is and does not convert or resample it.
  • Test fixtures. Tests for audio processing code can keep a tiny sample as a string constant.

When not to use Base64 for audio

Base64 adds about a third to the size, and the browser has to receive the entire string before playback can start. There is no streaming, no separate caching and no range requests for seeking. A 5-minute MP3 at 128 kbps is about 4.8 MB, which becomes roughly 6.4 MB of text inside your HTML or JavaScript, downloaded again whenever that file changes. For music, podcasts and other long recordings, serve a normal audio file. As a rule of thumb, inline only sounds that last a few seconds.

Audio formats and MIME types

FormatData URI prefixNotes
MP3data:audio/mpeg;base64,Compact, plays in every browser
WAVdata:audio/wav;base64,Uncompressed and large; fine for very short sounds
OGG (Vorbis, Opus)data:audio/ogg;base64,Compact; older Safari versions cannot play it
M4A (AAC)data:audio/mp4;base64,Compact, widely supported
FLACdata:audio/flac;base64,Lossless, much larger than MP3 or AAC

Depending on the operating system, a file may be reported with a variant type such as audio/x-wav or audio/x-m4a. Browsers generally play these too, and you can edit the prefix if a platform needs a specific type.

Frequently asked questions

What is the MIME type for MP3 in a data URI?
The registered type is audio/mpeg, so the data URI starts with data:audio/mpeg;base64,. You will also see audio/mp3 in the wild; some browsers accept it, but audio/mpeg is the safe choice.
Why does the preview not play my file?

The player relies on the codecs built into your browser. If the browser does not support a format, such as OGG in older Safari versions, the preview stays silent, but the Base64 output is still an exact copy of the file.

How long can a Base64 audio clip be?

The tool encodes files up to 100 MB, but that is far too large to embed. For inline use, keep clips to a few seconds and a few dozen kilobytes. For speech APIs, check the limit for inline audio, which is often much lower than for audio uploaded to storage.

Can I convert MP3 to WAV here?

No. The tool encodes the file as it is, without changing its format, bitrate or sample rate. Convert the audio first with an audio editor or a command-line tool such as FFmpeg, then encode the result.

Is my audio uploaded?

No. Encoding and playback happen in your browser, and the file stays on your device.