DEV Community

Instantconvert
Instantconvert

Posted on

The 2-Minute Trick to Trim Audio Without Uploading a Single File

I needed to cut a 10-second clip from a podcast episode for a social media post. Nothing complicated.

But every "free" audio cutter I found wanted me to upload my file to their server. For an unreleased episode, that wasn't happening.

So I built a different approach — one where everything runs locally in the browser.

The Core Logic
Modern browsers can decode, trim, and encode audio using the Web Audio API. No server required. Here's the essential JavaScript:

`async function trimAudio(audioBuffer, startSec, endSec) {
const sampleRate = audioBuffer.sampleRate;
const startSample = Math.floor(startSec * sampleRate);
const endSample = Math.floor(endSec * sampleRate);
const length = endSample - startSample;

const newBuffer = new AudioBuffer({
length: length,
numberOfChannels: audioBuffer.numberOfChannels,
sampleRate: sampleRate
});

for (let channel = 0; channel < audioBuffer.numberOfChannels; channel++) {
const source = audioBuffer.getChannelData(channel);
const dest = newBuffer.getChannelData(channel);
for (let i = 0; i < length; i++) {
dest[i] = source[startSample + i];
}
}
return newBuffer;
}`

That's it. The file stays in your browser's memory. Nothing gets uploaded.

Why This Matters
Privacy-first: Your audio never touches any server

Instant processing: No waiting for uploads or server queues

Works offline: After the initial page load, you can disconnect from the internet and it still works

No file size limits (up to 1GB): Since it's all local, you're only limited by your device's memory

The Result
I wrapped this logic into a free tool with a visual waveform, drag handles for precise cuts, multi-segment extraction, and ZIP export. You can trim, cut multiple parts from the same track, apply fades, and export as MP3 (320kbps), WAV (lossless), or OGG.

If you want to try it without installing anything:
šŸ‘‰ instantconvert.online/cut-audio-online-2/

No sign-up. No uploads. No watermark. Just a tool that works.

What audio tasks do you find yourself doing most often? Drop your suggestions in the comments - I'm looking to build more local-first tools.

Top comments (1)

Collapse
 
instantconvert profile image
Instantconvert •

give us comment is this tool helpful to you ?