Audio to Base64 Converter

Encode a sound file as Base64 and get a data URI, an audio element or a JavaScript snippet back.

Audio file

Drop a file here, paste from the clipboard, or choose one

MP3, WAV, OGG, M4A, FLAC, audio, processed in this tab

Base64
Runs locally in your browser

About the Audio to Base64 Converter

Short sounds are the ones worth inlining: a notification chime, a button click, a countdown beep. Embedding them removes a network request at the moment the sound is needed, which is precisely when a delay is most noticeable, and it makes a single file demo or an offline page self contained.

The format is identified from the file signature rather than the extension. WAV files start with a RIFF header, Ogg files with the letters OggS, FLAC with fLaC, M4A with an ftyp box, and MP3 with either an ID3 tag or a raw frame sync. That detection sets the media type in the data URI, which matters because a browser given the wrong type may refuse to play a perfectly good file. If nothing matches, the status line says so and the browser reported type is used instead.

Four output shapes are on offer beyond the raw payload. The data URI is the address itself. The audio element arrives with controls already set so it plays as soon as it is pasted into a page. The JavaScript snippet builds an Audio object and calls play, which is the shape you want for an event handler. The JSON object records the name, type and size next to the payload for an API call.

Size is the real constraint here. Audio does not compress further under Base64, it grows by a third, so anything past a few seconds belongs in a real file. For MP3 specific detail use MP3 to Base64, and save a payload back to disk with Base64 to File.

How to use

  1. Drop an audio file onto the panel or click to browse for one.
  2. Check that the detected format in the status line matches what you expected.
  3. Pick an Output as shape: data URI, audio element, JavaScript snippet or JSON.
  4. Copy the result into your page, script or request.

Common questions

Which audio formats are recognised?
WAV, MP3, Ogg, FLAC and M4A are identified from their file signatures, and anything else falls back to the type the browser reports.
How long a clip is reasonable to inline?
A second or two. Encoding adds a third to the size, and every page load pays for it whether the sound plays or not.
Will the audio element autoplay?
No. Browsers block autoplay without user interaction, which is why the generated element ships with visible controls.
Is my recording uploaded anywhere?
No. The file is read with the browser file API and encoded in the page, so nothing is sent over the network.