Skip to content

Instantly share code, notes, and snippets.

@widyakumara
Created August 14, 2025 17:21
Show Gist options
  • Save widyakumara/d4b1af4f8beb3adcac4acc3b706d0eda to your computer and use it in GitHub Desktop.
Save widyakumara/d4b1af4f8beb3adcac4acc3b706d0eda to your computer and use it in GitHub Desktop.
wite mp3 tag using mp3tag.js
import { readFileSync, writeFileSync } from "node:fs";
import MP3Tag from "mp3tag.js";
const file = "rick astley/whenever you need somebody/never gonna give you up.mp3";
const buffer = readFileSync(file);
const verbose = true;
const mp3tag = new MP3Tag(buffer, verbose);
mp3tag.read({ id3v1: false });
mp3tag.tags.artist = "Rick Astley";
mp3tag.tags.album = "Whenever You Need Somebody";
mp3tag.tags.track = "1";
mp3tag.tags.title = "Never Gonna Give You Up";
mp3tag.save({ strict: true });
writeFileSync(file, Buffer.from(mp3tag.buffer as ArrayBuffer));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment