Audio to Base64
Encode a sound file to Base64 and embed it directly in a web page, game or app. The audio to Base64 converter generates ready-made HTML5 and JavaScript snippets and lets you play the result to check it.
How to convert Audio to Base64 online
- Select an audio file or paste its URL.
- Choose the output format (data URI, <audio>, JavaScript Audio, ...).
- Click Encode audio to Base64 and test the player.
More Audio to Base64 converters
Output formats
Choose how the result should be wrapped. The converter can return:
- txt: only the Base64 string, ready to paste into code, a database field or an API request.
- uri: a complete
data:URI that you can paste in a browser address bar or use anywhere a URL is accepted. - html audio: an HTML5
<audio controls>player. - html source: a media element with a nested
<source>tag and MIME type. - html embed: an
<embed>tag. - html object: an
<object>tag with a type attribute. - html hyperlink: an
<a>link that downloads or opens the embedded file. - html iframe: an
<iframe>that renders the content inline. - javascript audio: JavaScript that creates and plays an
Audioobject. - javascript popup: JavaScript that opens the content in a new window.
- json: a JSON object with the file name, MIME type and data.
- xml: an XML element with the data inside a CDATA section.
Tips
Keep embedded audio short: notification sounds and UI effects are ideal. Prefer compressed formats (MP3, Ogg/Opus) to keep the Base64 string small.
Base64 represents every 3 bytes with 4 characters, so the encoded result is about 33% larger than the original file (plus a few bytes for padding and the data URI prefix).
Frequently asked questions
How do I play Base64 audio in HTML?
Use <audio controls src="data:audio/mpeg;base64,..."></audio>, or in JavaScript: new Audio("data:audio/mpeg;base64,...").play().
Which audio formats can browsers play?
MP3, WAV, Ogg (Vorbis/Opus), AAC/M4A and FLAC are supported by all modern browsers. WMA is not.
Comments (0)
Questions, ideas or a bug in “Audio to Base64”? Leave a comment, rate the tool, or reply to others.
No comments yet. Be the first to share your feedback!