How to use the PCM to WAV Base64 tool
- Choose a headerless audio file under Raw PCM file (optional), or paste Base64 into PCM bytes in Base64 if no file is selected.
- Enter the Sample rate (Hz) the audio was produced at, for example 24000 or 16000.
- Enter the number of Channels: 1 for mono, 2 for stereo.
- Select Build WAV, or select Example to convert a three-sample demo.
- Play the preview, copy the WAV Base64 from the Result box, or use the Download link to save audio.wav.
What the WAV header adds to raw PCM
PCM16 audio is a sequence of signed 16-bit integers, low byte first, one per channel for each sampling instant. Nothing in the data says how fast to play it or how many channels it has. A WAV file solves that by putting a RIFF header in front: a fmt chunk that records the format code, channel count, sample rate, byte rate, block size and bit depth, then a data chunk with the samples.
This tool writes the canonical 44-byte header for format code 1, uncompressed PCM, at 16 bits, using the rate and channel count you enter, and appends your bytes unchanged. It does not resample, convert bit depth or swap byte order.
Worked example: PCM to WAV at 24 kHz
The Example input AAD/fwCA decodes to 6 bytes: 00 00, FF 7F and 00 80. As little-endian 16-bit samples they are 0, 32767 and -32768, the midpoint and the two extremes of the range. With a 24,000 Hz mono setting the tool produces a 50-byte file: 44 header bytes and 6 data bytes.
The Base64 of every WAV file starts with UklGR, the encoding of the letters RIFF. The header in this example stores a byte rate of 48,000 and a block size of 2.
PCM Base64: AAD/fwCA
Sample rate: 24000 Channels: 1
WAV Base64:
UklGRioAAABXQVZFZm10IBAAAAABAAEAwF0AAIC7AAACABAAZGF0YQYAAAAAAP9/AIA=Getting the sample rate and channels right
The header values are whatever you type, and a wrong value still yields a valid file that sounds wrong. A rate that is too high plays fast and high-pitched. Mono data labeled as stereo plays at double speed, because each frame is read as two samples. Take both values from the documentation of the service that produced the audio. Speech APIs that stream headerless PCM commonly use 24,000 or 16,000 Hz mono.
- Sample rate: a whole number from 1,000 to 384,000.
- Channels: a whole number from 1 to 8.
- Data length: not empty and a multiple of 2 bytes times the channel count, otherwise PCM16 must have complete frames for the selected number of channels.
- File input: up to 20 MiB. A selected file takes priority over the Base64 box.
- Base64 input: standard or URL-safe, with or without padding or a data URL header.
When the converted audio is only noise
Loud static usually means the bytes are not 16-bit little-endian PCM. The source may be 8-bit, 24-bit, 32-bit float, big-endian, or a compressed codec such as mu-law, MP3 or Opus, none of which this tool converts.
When several Base64 chunks from a stream were pasted together as text, join them first with the Base64 Chunk Joiner set to Independently encoded blocks.
Frequently asked questions
How long is the audio for a given PCM size?
Divide the byte count by sample rate times channels times 2. At 24,000 Hz mono, one second is 48,000 bytes, so 480,000 bytes of PCM play for 10 seconds.
Can I convert 8-bit, 24-bit or float PCM?
No. The header always declares 16 bits per sample and integer PCM. Other sample formats would be mislabeled and play as noise. Convert them to 16-bit little-endian first with an audio tool.
Why do I get an error about complete frames?
A frame is one 16-bit sample for each channel, so its size is 2 bytes times the channel count. The tool refuses data that ends partway through a frame. Check the channel setting and whether the stream was cut off.
Is the audio uploaded for conversion?
No. The header is built in your browser and the preview plays from a local object URL. Recordings and generated speech stay on your device.