FormatterHQ

MP3 to Base64

Encode an MP3 file as Base64 — as a data URI for an HTML audio element or as raw Base64 for APIs — and listen to the result in a preview player.

Input TEXT
Output TEXT
Ready.

How to use the MP3 to Base64

  1. Drop an MP3 file onto the upload area, or click it to choose one from your device.
  2. Choose Data URI for use in an audio element, or Raw Base64 for APIs.
  3. Click Convert if the result does not appear automatically, and play the preview to check it.
  4. Copy the Base64 output or download it as a text file.

MP3 to Base64 for embedded sound

The MP3 to Base64 converter encodes an audio file as text so it can be embedded in HTML, JavaScript or JSON. With the Data URI output you get data:audio/mpeg;base64,…, which works directly as the src of an <audio> element or with the JavaScript Audio constructor. A preview player lets you confirm the encoded audio plays correctly.

Using the output

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

new Audio("data:audio/mpeg;base64,SUQzBAAAAAAA…").play();

MP3 files that begin with an ID3 metadata tag start with the bytes ID3, which is why their Base64 usually begins with SUQz. Files without a tag start with an MPEG frame header instead (often // in Base64).

Playing embedded clips with the Web Audio API

An <audio> element is fine for occasional sounds, but games and interactive apps usually decode clips once into an AudioBuffer so they can play instantly and overlap. Use the Raw Base64 output:

const bytes = Uint8Array.from(atob(clip), (c) => c.charCodeAt(0));
const buffer = await audioCtx.decodeAudioData(bytes.buffer);

const source = audioCtx.createBufferSource();
source.buffer = buffer;
source.connect(audioCtx.destination);
source.start();

To predict the size before encoding, multiply the bitrate by the duration: a 3-second effect at 64 kbps is 64,000 ÷ 8 × 3 = 24,000 bytes, which grows to about 32 KB as Base64. That is a reasonable cost for a sound the app needs immediately.

Good use cases

  • Short UI sounds — clicks, notifications, success chimes — bundled in a web app or browser extension without extra files.
  • Games and single-file demos that must run offline or from one HTML file.
  • Speech and audio APIs that accept audio clips as Base64 in a JSON body.
  • Test fixtures for audio-processing code.

Size considerations

Audio adds up quickly: one minute of 128 kbps MP3 is roughly 1 MB, or about 1.3 MB as Base64. Embedding long tracks makes pages and scripts slow to load and prevents the browser from streaming or caching the audio separately. Keep embedded clips to a few seconds, lower the bitrate for effects (64 kbps mono is often enough), and serve music or podcasts as normal files.

Autoplay rules

Browsers block audio from playing automatically until the user has interacted with the page, whether the source is a file or a data URI. Trigger play() from a click or key press, and handle the promise it returns so a blocked attempt does not cause an unhandled error.

Other audio formats

The tool is designed for MP3, the most widely supported audio format. For other file types — WAV, OGG, fonts or documents — use File to Base64, which accepts anything and picks the MIME type from the file. To check the start of an encoded file, Base64 to Hex shows its first bytes. As with images, only embed audio you have the right to use.

The file is read and encoded locally in your browser; it is never uploaded.

Frequently asked questions

How do I play a Base64 MP3 in HTML?
Put the data URI in the src attribute of an audio element, for example <audio controls src="data:audio/mpeg;base64,…">, or pass it to new Audio() in JavaScript.
What MIME type is used for MP3?
audio/mpeg. It is the registered type for MP3 audio and is supported by all modern browsers.
Why does my MP3 Base64 start with SUQz?
SUQz is the Base64 encoding of “ID3”, the metadata tag that starts most MP3 files.
Is it a good idea to embed songs this way?
Only for very short clips. Long audio becomes large Base64 strings that cannot be streamed or cached, so serve it as a regular file instead.

Last updated September 26, 2026

Related tools