MP3 to Base64 Converter
Encode MP3, WAV, OGG, M4A or FLAC into Base64 and a working HTML audio tag.
Your files are processed on your device and are never uploaded.
Encode an MP3 – or WAV, OGG, M4A, FLAC, AAC or Opus – into Base64 and get a working HTML <audio> tag with the sound built in. Useful for notification sounds in a web app, audio in a single-file HTML page, or sending a clip through an API that only accepts text.
How to Convert Audio to Base64
- Choose the audio file. You can play it in the preview to check it is the right one.
- Copy what you need: the raw Base64, the data URI (
data:audio/mpeg;base64,…) or the complete<audio controls>tag. - Paste it into your HTML, JavaScript or JSON.
Using It in JavaScript
A data URI works anywhere a URL does, so a short UI sound can be played without loading a file:
new Audio('data:audio/mpeg;base64,SUQzBAAAAAAA…').play();
Browsers only play sound after the user has interacted with the page, so trigger it from a click or key press.
Keep Clips Short
Base64 adds about a third to the size, and the whole string has to load before the page can use it. A one-second click sound at 128 kbps is around 16 KB – perfect for inlining. A three-minute song would become several megabytes of text inside your page, which is better served as a normal file.
To make a clip smaller first, cut it with Audio Cutter and lower the bitrate with MP3 Bitrate Changer – 64 kbps mono is plenty for alerts and voice prompts.
Which Format to Encode?
- MP3 plays in every browser – the safest choice.
- M4A/AAC sounds better at low bitrates and plays in all current browsers.
- OGG/Opus is very efficient but older Safari versions do not support it.
- WAV is uncompressed and gets very large – avoid it for inlining.
Private
The file is encoded in your browser and never uploaded. To turn Base64 back into an audio file, use Base64 to File.
Base64 to File Video to Base64 File to Base64 Cut Audio MP3 Bitrate Changer
Frequently Asked Questions
How do I convert MP3 to Base64?
How do I play a Base64 MP3 in HTML?
<audio controls src="data:audio/mpeg;base64,…"></audio>. The tool gives you this tag ready-made.