TagLib-Wasm
Guide
API Reference
Examples
NPM
JSR
GitHub
Guide
API Reference
Examples
NPM
JSR
GitHub
  • Documentation

    • taglib-wasm API Reference
    • /api/tag-name-constants.html
    • Extended Metadata with PropertyMap API
    • Runtime Compatibility
    • Memory Management
    • Performance Guide
    • Error Handling Guide
    • Implementation Guide
    • Troubleshooting Guide
    • Publishing Guide
    • Cloudflare Workers

TagLib Tag Name Constants and Cross-Format Mapping

This document provides a comprehensive reference for TagLib's standard tag names and how they map across different audio formats.

Overview

TagLib uses a PropertyMap system to provide format-independent tag access. This allows you to use consistent tag names across different audio formats (MP3, MP4, FLAC, OGG, WAV, etc.).

TypeScript Constants

Enhanced PROPERTIES Constant (Recommended)

taglib-wasm provides a comprehensive PROPERTIES constant with rich metadata for all standard properties:

import { PROPERTIES, PropertyKey } from "taglib-wasm/constants";

// Access property metadata
const titleProp = PROPERTIES.TITLE;
console.log(titleProp.description); // "The title of the track"
console.log(titleProp.type); // "string"
console.log(titleProp.supportedFormats); // ["ID3v2", "MP4", "Vorbis", "WAV"]
console.log(titleProp.mappings.id3v2.frame); // "TIT2"

// Use for type-safe property access
const title = file.getProperty(PROPERTIES.TITLE.key);
const artist = file.getProperty(PROPERTIES.ARTIST.key);

// Iterate through all known properties with metadata
Object.values(PROPERTIES).forEach((prop) => {
  const value = file.getProperty(prop.key);
  if (value !== undefined) {
    console.log(`${prop.key}: ${value}`);
    console.log(`  Description: ${prop.description}`);
    console.log(`  Type: ${prop.type}`);
    console.log(`  Formats: ${prop.supportedFormats.join(", ")}`);
  }
});

Legacy Tags Object

The Tags object provides a simplified approach for common property names and remains fully supported:

import { Tags } from "taglib-wasm";

// Use constants instead of strings
const title = properties[Tags.Title]?.[0]; // Instead of properties["TITLE"]
const artist = properties[Tags.Artist]?.[0]; // Instead of properties["ARTIST"]
const bpm = properties[Tags.Bpm]?.[0]; // Instead of properties["BPM"]

// Constants map to the standard property names
console.log(Tags.Title); // "TITLE"
console.log(Tags.AlbumArtist); // "ALBUMARTIST"
console.log(Tags.TrackGain); // "REPLAYGAIN_TRACK_GAIN"

Utility Functions

import {
  getAllPropertyKeys,
  getPropertiesByFormat,
  getPropertyMetadata,
  isValidProperty,
} from "taglib-wasm/constants";

// Check if a property is valid
isValidProperty("ACOUSTID_ID"); // true
isValidProperty("INVALID_KEY"); // false

// Get metadata about a property
const metadata = getPropertyMetadata("MUSICBRAINZ_TRACKID");
console.log(metadata.description); // "MusicBrainz Track ID"

// Get all available property keys
const allKeys = getAllPropertyKeys(); // ["TITLE", "ARTIST", "ALBUM", ...]

// Get properties supported by a specific format
const mp3Properties = getPropertiesByFormat("MP3");
const flacProperties = getPropertiesByFormat("FLAC");

See the tag-constants.ts example for a complete demonstration.

Standard Property Names

These are the well-known property names defined in TagLib's PropertyMap (tpropertymap.h):

Basic Tags

Property NameDescriptionExample
TITLETrack title"Bohemian Rhapsody"
ARTISTTrack artist"Queen"
ALBUMAlbum name"A Night at the Opera"
ALBUMARTISTAlbum artist (for compilations)"Various Artists"
SUBTITLETrack subtitle"Live Version"
TRACKNUMBERTrack number"11" or "11/12"
DISCNUMBERDisc number"1" or "1/2"
DATERelease date"1975" or "1975-10-31"
ORIGINALDATEOriginal release date"1975"
GENREMusical genre"Rock"
COMMENTGeneral comment"Remastered edition"

Sort Names

Property NameDescription
TITLESORTTitle for sorting
ALBUMSORTAlbum name for sorting
ARTISTSORTArtist name for sorting
ALBUMARTISTSORTAlbum artist for sorting
COMPOSERSORTComposer name for sorting

Credits

Property NameDescription
COMPOSERTrack composer
LYRICISTLyrics writer
CONDUCTOROrchestra conductor
REMIXERTrack remixer
PERFORMER:<instrument>Performer with instrument (e.g., PERFORMER:VOCALS)

Additional Metadata

Property NameDescription
ISRCInternational Standard Recording Code
ASINAmazon Standard Identification Number
BPMBeats per minute
COPYRIGHTCopyright notice
ENCODEDBYPerson/software that encoded the file
MOODTrack mood
MEDIAOriginal media type
LABELRecord label
CATALOGNUMBERLabel catalog number
BARCODERelease barcode (UPC/EAN)
RELEASECOUNTRYCountry of release
RELEASESTATUSRelease status (official, bootleg, etc.)
RELEASETYPERelease type (album, single, EP, etc.)
LANGUAGELanguage of lyrics/content
WORKLarger work (e.g., "Symphony No. 5")
MOVEMENTNAMEMovement name within a work
MOVEMENTNUMBERMovement number/index
LENGTHTrack length in milliseconds
COMPILATIONPart of a compilation (1 = yes, 0 = no)
ORIGINALALBUMOriginal album name
ORIGINALARTISTOriginal artist name
ORIGINALLYRICISTOriginal lyricist
OWNERFile owner/purchaser

MusicBrainz Identifiers

Property NameDescription
MUSICBRAINZ_TRACKIDMusicBrainz track ID
MUSICBRAINZ_ALBUMIDMusicBrainz release ID
MUSICBRAINZ_RELEASEGROUPIDMusicBrainz release group ID
MUSICBRAINZ_RELEASETRACKIDMusicBrainz release track ID
MUSICBRAINZ_WORKIDMusicBrainz work ID
MUSICBRAINZ_ARTISTIDMusicBrainz artist ID
MUSICBRAINZ_ALBUMARTISTIDMusicBrainz album artist ID
ACOUSTID_IDAcoustID audio fingerprint ID
ACOUSTID_FINGERPRINTAcoustID audio fingerprint data
MUSICIP_PUIDMusicIP PUID (deprecated)

Podcast Properties

Property NameDescription
PODCASTPodcast flag (1 = yes, 0 = no)
PODCASTCATEGORYPodcast category
PODCASTDESCPodcast description
PODCASTIDPodcast identifier
PODCASTURLPodcast feed URL

Format-Specific Tag Mapping

ID3v2 (MP3) Frame Mapping

ID3v2 uses 4-character frame IDs that map to property names:

Frame IDProperty NameDescription
TIT2TITLETitle
TPE1ARTISTLead artist/performer
TALBALBUMAlbum
TPE2ALBUMARTISTAlbum artist
TRCKTRACKNUMBERTrack number
TPOSDISCNUMBERDisc number
TDRCDATERecording date (ID3v2.4)
TDORORIGINALDATEOriginal release date
TCONGENREContent type (genre)
COMMCOMMENTComments
TCOMCOMPOSERComposer
TEXTLYRICISTLyricist
TPE3CONDUCTORConductor
TPE4REMIXERRemixer
TBPMBPMBeats per minute
TCOPCOPYRIGHTCopyright
TENCENCODEDBYEncoded by
TMOOMOODMood
TMEDMEDIAMedia type
TPUBLABELPublisher
TSRCISRCISRC
TLANLANGUAGELanguage
TIT1WORKContent group (work)
TIT3SUBTITLESubtitle
TSOAALBUMSORTAlbum sort order
TSOPARTISTSORTPerformer sort order
TSOTTITLESORTTitle sort order
TSO2ALBUMARTISTSORTAlbum artist sort (iTunes)
TSOCCOMPOSERSORTComposer sort order
TCMPCOMPILATIONCompilation (iTunes)
PCSTPODCASTPodcast (iTunes)
TCATPODCASTCATEGORYPodcast category (iTunes)
TDESPODCASTDESCPodcast description (iTunes)
TGIDPODCASTIDPodcast ID (iTunes)
WFEDPODCASTURLPodcast URL (iTunes)

MP4/M4A Atom Mapping

MP4 uses atom codes (often 4 characters starting with ©):

AtomProperty NameDescription
©namTITLEName/Title
©ARTARTISTArtist
©albALBUMAlbum
aARTALBUMARTISTAlbum artist
trknTRACKNUMBERTrack number
diskDISCNUMBERDisc number
©dayDATEYear/Date
©genGENREGenre
©cmtCOMMENTComment
©wrtCOMPOSERWriter/Composer
©lyrLYRICSLyrics
tmpoBPMTempo
cprtCOPYRIGHTCopyright
©tooENCODINGEncoding tool
©encENCODEDBYEncoded by
©grpGROUPINGGrouping
cpilCOMPILATIONCompilation
soalALBUMSORTSort album
soarARTISTSORTSort artist
sonmTITLESORTSort name
soaaALBUMARTISTSORTSort album artist
socoCOMPOSERSORTSort composer
©wrkWORKWork name
©mvnMOVEMENTNAMEMovement name
©mviMOVEMENTNUMBERMovement number
©mvcMOVEMENTCOUNTMovement count
pcstPODCASTPodcast
catgPODCASTCATEGORYCategory
descPODCASTDESCDescription
egidPODCASTIDEpisode ID
purlPODCASTURLPodcast URL

MP4 also supports freeform atoms using the ----:com.apple.iTunes: prefix:

Freeform AtomProperty Name
----:com.apple.iTunes:MusicBrainz Track IdMUSICBRAINZ_TRACKID
----:com.apple.iTunes:MusicBrainz Album IdMUSICBRAINZ_ALBUMID
----:com.apple.iTunes:MusicBrainz Artist IdMUSICBRAINZ_ARTISTID
----:com.apple.iTunes:ACOUSTID_IDACOUSTID_ID
----:com.apple.iTunes:ACOUSTID_FINGERPRINTACOUSTID_FINGERPRINT
----:com.apple.iTunes:ISRCISRC
----:com.apple.iTunes:LABELLABEL
----:com.apple.iTunes:CATALOGNUMBERCATALOGNUMBER
----:com.apple.iTunes:BARCODEBARCODE

Vorbis Comments (OGG, FLAC)

Vorbis Comments generally use the property names directly as field names, making them the most straightforward:

  • TITLE → TITLE
  • ARTIST → ARTIST
  • ALBUM → ALBUM
  • ALBUMARTIST → ALBUMARTIST
  • TRACKNUMBER → TRACKNUMBER
  • DATE → DATE
  • GENRE → GENRE
  • COMMENT → COMMENT
  • etc.

Vorbis Comments are case-insensitive but conventionally use uppercase.

RIFF INFO (WAV)

WAV files use INFO chunks with specific FourCC codes:

INFO TagProperty NameDescription
INAMTITLEName (Title)
IARTARTISTArtist
IPRDALBUMProduct (Album)
ICMTCOMMENTComment
ICRDDATECreation date
IGNRGENREGenre
ICOPCOPYRIGHTCopyright
ISFTENCODEDBYSoftware
ITRKTRACKNUMBERTrack number

Usage Examples

Reading Tags (TypeScript)

import { TagLib } from "taglib-wasm";
import { PROPERTIES, Tags } from "taglib-wasm/constants";

const taglib = await TagLib.initialize();
const file = taglib.openFile(audioBuffer);

// Using PROPERTIES constant (recommended - provides rich metadata)
const properties = file.properties();
const title = file.getProperty(PROPERTIES.TITLE.key);
const artist = file.getProperty(PROPERTIES.ARTIST.key);
const musicBrainzId = file.getProperty(PROPERTIES.MUSICBRAINZ_TRACKID.key);

// Using legacy Tags constants (still supported)
const title2 = properties[Tags.Title]?.[0];
const artist2 = properties[Tags.Artist]?.[0];
const album = properties[Tags.Album]?.[0];

// Or using string property names directly
const title3 = properties["TITLE"]?.[0];
const artist3 = properties["ARTIST"]?.[0];

Writing Tags (TypeScript)

// Using PROPERTIES constant (recommended)
file.setProperty(PROPERTIES.TITLE.key, "My Song Title");
file.setProperty(PROPERTIES.ARTIST.key, "Artist Name");
file.setProperty(PROPERTIES.ALBUMARTIST.key, "Album Artist");
file.setProperty(
  PROPERTIES.MUSICBRAINZ_TRACKID.key,
  "123e4567-e89b-12d3-a456-426614174000",
);

// Or set multiple properties at once
file.setProperties({
  [PROPERTIES.TITLE.key]: ["My Song Title"],
  [PROPERTIES.ARTIST.key]: ["Artist Name"],
  [PROPERTIES.ALBUMARTIST.key]: ["Album Artist"],
  [PROPERTIES.MUSICBRAINZ_TRACKID.key]: [
    "123e4567-e89b-12d3-a456-426614174000",
  ],
});

// Using legacy Tags constants
file.setProperties({
  [Tags.Title]: ["My Song Title"],
  [Tags.Artist]: ["Artist Name"],
  [Tags.AlbumArtist]: ["Album Artist"],
  [Tags.MusicBrainzTrackId]: ["123e4567-e89b-12d3-a456-426614174000"],
});

// Save changes
file.save();
const outputBuffer = file.toBuffer();

Cross-Format Compatibility

When using the PropertyMap interface, TagLib automatically handles the format-specific mappings:

// This works the same for MP3, MP4, FLAC, OGG, and WAV files
file.tag.properties.set("TITLE", "Universal Title");
file.tag.properties.set("COMPOSER", "Universal Composer");

// TagLib converts these to:
// - MP3: TIT2 and TCOM frames
// - MP4: ©nam and ©wrt atoms
// - FLAC/OGG: TITLE and COMPOSER vorbis comments
// - WAV: INAM INFO chunk (COMPOSER may not be supported)

Special Considerations

Unsupported Properties

Not all formats support all properties. When a property is not supported:

  • Reading returns an empty value
  • Writing is ignored or stored in format-specific extension mechanisms
  • Use file.tag.properties.unsupportedData() to see what couldn't be mapped

Multiple Values

Some formats support multiple values for a single property:

  • Vorbis Comments naturally support multiple values
  • ID3v2 can have multiple frames of the same type
  • MP4 generally supports only single values

Case Sensitivity

  • Property names in the PropertyMap are case-sensitive
  • Vorbis Comments are case-insensitive but conventionally uppercase
  • ID3v2 frame IDs are always uppercase
  • MP4 atoms are case-sensitive

Complex Properties

Some properties require special handling:

  • PICTURE: Embedded album art (use complexProperties())
  • LYRICS: May include synchronized lyrics in some formats
  • PERFORMER:<instrument>: Instrument-specific performer credits

Best Practices

  1. Use Standard Names: Always use the standard property names from this document for maximum compatibility.

  2. Check Format Support: Be aware that not all formats support all properties.

  3. Handle Missing Values: Always check if a property exists before using its value.

  4. Preserve Unknown Tags: Use properties() and setProperties() to preserve tags you don't explicitly handle.

  5. Test Across Formats: If your application needs to work with multiple formats, test tag operations with each format.

References

  • ID3v2 Specification
  • Vorbis Comment Specification
  • MP4 Metadata Atoms
  • RIFF INFO Specification
Edit this page on GitHub
Last Updated:: 6/23/25, 3:15 AM
Contributors: Charles Wiltgen, Claude