Convert audio to a Base64 data URI, and Base64 back to audio

Encode turns an audio file into text you can paste straight into HTML, CSS, JSON or JavaScript; Decode takes that text and rebuilds the original file so you can play and save it.

Live demo · real result from this tool
Direction
Output

Drop your audio file here

or paste with Ctrl+V · nothing is uploaded

Your result appears here — nothing is uploaded.

Processed on your device — nothing is uploaded.

How to use the Base64 converter

To encode a sound:

  1. Set Direction to Audio → Base64.
  2. Choose the Output: Data URI (data:audio/…;base64,…), Raw Base64, or a complete <audio> tag with controls.
  3. Drop an audio file or press Choose a file. A player appears so you can check it.
  4. Press Encode to Base64, then copy the text or download it as a .b64.txt file.

To decode:

  1. Set Direction to Base64 → audio.
  2. Paste a data URI or raw Base64 into Data URI or Base64.
  3. Press Decode to audio. You get a player, the detected Type and Size, and a download named decoded-audio with a matching extension.

What it does and when to use it

A data URI puts a whole file inside a line of text. That is handy for a short click or notification sound in a single-file HTML page, an email template, a code sample, a test fixture, or a JSON settings file that cannot reference separate files. Decoding is the reverse: you found a long data:audio/mpeg;base64,… string in a web page or an API response and want to hear it or save it.

Keep embedded sounds short. Trim them first with the audio trimmer, and save them as M4A or OGG with the audio converter to cut the size before encoding. For pictures, use image to Base64; for plain text there is a general Base64 encoder.

How it works

Everything runs on the page itself; no file or text is sent anywhere. Encoding reads the file’s bytes and converts them to Base64 in chunks so large files do not crash the browser. The MIME type comes from the file, or from its first bytes if the browser does not report one. Decoding accepts either a data URI or bare Base64, ignores spaces and line breaks, accepts the URL-safe alphabet (- and _), adds missing = padding, and rejects anything else. The audio is not decoded or re-encoded, so the bytes come back exactly as they went in.

Worked examples

From the tool’s own output:

  • Encode a 0.25-second WAV beep (10.8 KB) as a Data URI: Encoded length 14,782 chars, Type audio/wav. The text starts with data:audio/wav;base64,UklGR, the Base64 form of the “RIFF” header every WAV begins with.
  • Decode data:audio/wav;base64,UklGRiQAAABXQVZFZm10IBAAAAABAAEAQB8AAIA+AAACABAAZGF0YQAAAAA=: Type audio/wav, Size 44 B, a valid but empty WAV saved as decoded-audio.wav.
  • Decode the same text without the data: prefix: the type is still detected as audio/wav from its bytes.
  • Decode data:audio/wav,hello: “This data URI is not Base64-encoded.”

Limits and tips

  • Encoding only accepts files the browser lists as audio.
  • Very large files make huge strings that can slow the page; keep data URIs to small sounds.
  • Some email programs block data URIs in messages, so test before sending.

Frequently asked questions

How much bigger does Base64 make a file?
About a third bigger. Every 3 bytes become 4 text characters, so a 10.8 KB WAV becomes a data URI of 14,782 characters.
When should I not use a data URI?
For anything large. Over about 100 KB the tool shows a note: a data URI bloats your HTML or CSS, has to be downloaded again with every page that contains it, and cannot be cached on its own. Link to a normal file instead.
My Base64 has no data:audio prefix. Will decoding work?
Yes. Raw Base64 is accepted, and the tool guesses the type from the first bytes of the file: WAV, MP3, OGG, FLAC, MP4/M4A, WebM or AAC. If it cannot tell, the file is saved as .bin.
Does decoding check that the audio actually plays?
No. It checks the text is valid Base64 and rebuilds the bytes exactly. Whether those bytes are a working sound file depends on what was encoded. Use the built-in player to listen before you rely on it.

Written by the ToolsRift team · Last updated

Pages are drafted with AI assistance and checked by automated tests. How we write and check pages.

Was this tool useful?

Report a problem

Start typing to search every tool.

↑ ↓ to moveEnter to openEsc to close