Skip to content
🎵 ID3 parsing and writing library for Go
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
testdata Delete e field from xencodingWrapper May 17, 2018
LICENSE First commit! May 15, 2016
buf_writer.go Fix parsing and writing synchunsafe sizes, that are used in id3v2.3 Aug 15, 2018
common_ids.go Expose Tag's default encoding, add AddTextFrame method Sep 27, 2018
encoding_test.go Use own bufWriter Apr 7, 2018
id3v2.go Add encoding conversion support Aug 24, 2017
options.go Add id3v2.Options May 1, 2017
parse_test.go Make small improvements Aug 25, 2018
pools.go Fix getByteSlice Apr 7, 2018
size.go Fix parsing and writing synchunsafe sizes, that are used in id3v2.3 Aug 15, 2018
size_test.go Add more tests Aug 15, 2018
tag.go Shorten Add*Frame funcs Sep 27, 2018
tag_test.go Make small refactoring Aug 25, 2018
ufid_frame.go Add convenient ReadText func Aug 25, 2018

id3v2 GoDoc Build Status

Fast, simple and powerful ID3 parsing and writing library for Go, based only on standard library.

id3v2 can:

  • support of ID3v2.3 and ID3v2.4 tags;
  • parse and write tags;
  • work with all available encodings;
  • set and read all text frames, unsynchronised lyrics/text (USLT), comments, attached pictures, UFID and TXXX frames;
  • set and read frames, that can be used multiple times in tag;
  • be used in multiple goroutines.

id3v2 can't:

  • work with unsynchronization, extended header, flags, padding, footer.

If you want some functionality, that library can't do, or you have some questions, just write an issue. And of course, pull requests are welcome!


go get -u

Example of usage

package main

import (


func main() {
	// Open file and parse tag in it.
	tag, err := id3v2.Open("file.mp3", id3v2.Options{Parse: true})
	if err != nil {
 		log.Fatal("Error while opening mp3 file: ", err)
	defer tag.Close()

	// Read frames.

	// Set simple text frames.
	tag.SetArtist("New artist")
	tag.SetTitle("New title")

	// Set comment frame.
	comment := id3v2.CommentFrame{
		Encoding:    id3v2.EncodingUTF8,
		Language:    "eng",
		Description: "My opinion",
		Text:        "Very good song",

	// Write it to file.
	if err = tag.Save(); err != nil {
		log.Fatal("Error while saving a tag: ", err)

Read multiple frames

pictures := tag.GetFrames(tag.CommonID("Attached picture"))
for _, f := range pictures {
	pic, ok := f.(id3v2.PictureFrame)
	if !ok {
		log.Fatal("Couldn't assert picture frame")

	// Do something with picture frame.
	// For example, print the description:


// Options influence on processing the tag.
type Options struct {
	// Parse defines, if tag will be parsed.
	Parse bool

	// ParseFrames defines, that frames do you only want to parse. For example,
	// `ParseFrames: []string{"Artist", "Title"}` will only parse artist
	// and title frames. You can specify IDs ("TPE1", "TIT2") as well as
	// descriptions ("Artist", "Title"). If ParseFrame is blank or nil,
	// id3v2 will parse all frames in tag. It works only if Parse is true.
	// It's very useful for performance, so for example
	// if you want to get only some text frames,
	// id3v2 will not parse huge picture or unknown frames.
	ParseFrames []string

Work with encodings

id3v2 can encode and decode text of avaialble encodings (ISO-8859-1, UTF-16 with BOM, UTF-16BE without BOM, UTF-8). Just set the desired encoding in Encoding field of frame and set UTF-8 encoded text to corresponding text fields.

For example, if you set comment frame with custom encoding and write it:

tag := id3v2.NewEmptyTag()
comment := id3v2.CommentFrame{
	Encoding:    id3v2.EncodingUTF16,
	Language:    "ger",
	Description: "Tier",
	Text:        "Der Löwe",

_, err := tag.WriteTo(w)
if err != nil {

Text field will be automatically encoded with UTF-16BE with BOM and written to w.

By default, if version of tag is 4 then UTF-8 is used for methods like SetArtist, SetTitle, SetGenre and etc, otherwise ISO-8859-1.


See benchmarks in the description of last release.


You can’t perform that action at this time.