BOiNK SFX Synth can export what it makes as WAV, MP3, FLAC and (on devices that support it) AAC. The first three were easy: the browser or a small library already does the work. FLAC was the awkward one. Browsers can play FLAC, but none of them can encode it — WebCodecs has no FLAC encoder. So an app that wants to save a FLAC file has to bring its own.
The options we found — libflac.js, @mediabunny/flac-encoder, flac.wasm — are all the reference FLAC library compiled to WebAssembly. That works, and it is fast, but it means shipping a binary alongside the page and loading it at run time. We wanted the export code to be one plain script with nothing to fetch. So we wrote an encoder from scratch, shipped it inside BOiNK, and now we are releasing it for anyone to use: microflac.js, MIT licensed, on GitHub.
Using it
<script src="microflac.js"></script>
<script>
const flac = microflac.encode({ channels: [left, right], sampleRate: 44100, bitsPerSample: 16 });
const blob = new Blob([flac], { type: "audio/flac" }); // flac is a Uint8Array
</script>
It takes one typed array per channel (or one interleaved array), floats from −1 to 1 or integers, and returns the finished file. There is an async version that yields to the event loop between blocks, a streaming encoder for feeding audio in pieces, and an ES-module build. It has no DOM access, so it also runs inside a Web Worker and in Node.
What it does
The output is a valid FLAC stream with a proper header — including the MD5 checksum of the original audio — and checksums on every frame. The default setting squeezes hard: for each 4096-sample block it tries all four stereo modes and keeps whichever comes out smallest, tries a range of predictors up to order 12 over six different analysis windows, searches the precision of the predictor coefficients, and finds the best entropy-coding partitioning. A "fast" setting trades a little size for speed.
The numbers
All measured in Chromium on one Windows PC; yours will differ.
| What | Result |
|---|---|
| Code size | 29.8 KB as shipped (with licence and comments); about 24 KB stripped of comments; 9.9 KB gzipped (8.0 KB stripped and gzipped) |
| File size vs. libFLAC's maximum preset (WebAssembly build) | Smaller on all 24 test files, 0.904 to 0.999 of libFLAC's size, 0.982 overall (about 2% smaller on average, up to about 10% on a few clips) |
| Speed, 10 s of 44.1 kHz stereo | about 2.2 s at the default setting, about 0.34 s at "fast" (files about 1% larger) |
| Speed of libFLAC-in-WebAssembly, same kind of clip | about 0.13 s — roughly 17 times faster than microflac's default |
So this is not a speed story. If you encode long files on the main thread, use a Worker or the async API; for short sound effects, like BOiNK's, 2 seconds for ten seconds of stereo is fine, and the files come out a little smaller.
How we tested it — and what we have not
The test page in the download runs 311 checks in your own browser, offline. Every file is checked three ways: by a separate reference decoder written for the page (bit-exact, and it verifies every checksum and header field), against a second, independently written MD5, and by the browser's own decoder. The cases cover silence, a full-scale square wave, white noise and sine waves; lengths of 1, 2, 4095, 4096, 4097 and 4608 samples; mono and stereo; 8, 16 and 24 bit; nine sample rates; three and six channels; and the streaming, async and ES-module paths. Everything passed.
The honest limits: it is an encoder only, and the file contains just the required header block — no tags, seek table or cover art. It handles 8, 16 and 24 bit and up to 8 channels (we tested 1, 2, 3 and 6). We compared sizes on BOiNK's own short sound-effect clips, not on a large independent music corpus, and we checked decoding with Chromium's decoder and our reference decoder — not with the flac command-line tool or a range of players. If you find a file it gets wrong, we want to know.
Download
The source is on GitHub: github.com/dialersapps/microflac (issues and pull requests welcome). The downloads below are plain files with nothing to build, no tracking and no outside requests:
- microflac-1.0.0.zip — everything below in one file (encoder, ES module, test page, README, licence)
- microflac.js — the encoder (works with a plain script tag,
require()and Workers) - microflac.mjs — the same code as an ES module
- test.html — the in-browser test suite (serve the folder over http to run every check)
- README.md — API, formats, limits
- LICENSE — MIT, copyright Dialer's Apps 2026
The code was written from scratch against the FLAC specification; it is not derived from libFLAC or any other encoder.