AdvertisementLeaderboard / responsive slot
M3U format • Technical guide

M3U Syntax Explained: Lines, Directives, Attributes & URLs

M3U syntax is line-oriented. Directives and comments begin with #, while media locations appear on ordinary lines. In Extended M3U, an #EXTINF line describes the media location that follows it.

Quick answer

M3U syntax is line-oriented. Directives and comments begin with #, while media locations appear on ordinary lines. In Extended M3U, an #EXTINF line describes the media location that follows it.

The line-oriented model

An M3U parser normally reads the file from top to bottom. Blank lines are usually ignored. Lines beginning with # are metadata, comments or format directives; other lines are treated as media locations. This simple model is why M3U is easy to generate but also why one misplaced line can attach metadata to the wrong stream.

The #EXTM3U header

Extended M3U commonly begins with #EXTM3U. The header identifies the file as an extended playlist and may itself carry global attributes used by some IPTV applications. A missing header does not make every basic M3U playlist invalid, but it is expected when the document relies on #EXTINF metadata.

#EXTM3U
#EXTINF:-1,Example Channel
https://example.org/live.m3u8
AdvertisementIn-content responsive slot

How #EXTINF is parsed

#EXTINF uses a colon, a duration field, optional attributes and then a comma before the display title. For live streams the duration is commonly -1. The comma is important because parsers use it to separate the metadata portion from the visible channel name.

#EXTINF:-1 tvg-id="example.uk" group-title="News",Example News

Attribute quoting rules

Attribute values should be quoted, particularly when they contain spaces. Keep the attribute name, equals sign and opening quote together; inconsistent spacing is tolerated by some parsers but not all. Attribute names are often treated case-sensitively by simple applications, so use established lowercase forms such as tvg-id and group-title.

URL and path lines

The line after #EXTINF is typically an absolute URL, but local paths and relative references are possible. Relative paths are resolved against the playlist location, which can behave differently when the file is opened locally versus downloaded from a website. For portable public playlists, absolute HTTPS URLs are usually easier to reason about.

Common syntax failures

Frequent problems include missing commas in #EXTINF, unmatched quote characters, #EXTINF lines with no following location, duplicate headers copied into the middle of a merged playlist, invisible byte-order marks, and metadata copied from one entry onto another. The M3U Checker is designed to surface these structural issues without attempting to contact the streams.

Practical workflow for M3U Syntax Explained

A reliable way to work with M3U Syntax Explained is to create a small reproducible test before changing a production playlist or player configuration. Begin with the concepts covered above—The line-oriented model, The #EXTM3U header, How #EXTINF is parsed—and confirm the expected result at each stage. Keep an untouched copy of the original playlist and reduce the problem to one or two entries before making bulk changes. Treat each metadata block and its following media location as one record. When identifiers are involved, preserve them deliberately rather than regenerating them from display names. This approach gives you a baseline that can be repeated after every change, which is far more useful than making several edits and then trying to infer which one affected the result.

Once the basic case behaves as expected, expand the test to the remaining areas: Attribute quoting rules, URL and path lines, Common syntax failures. For format work, correctness has two separate meanings: the text can be structurally valid and the referenced media can still be unavailable. Validate the document first, then test network locations independently. Save output as UTF-8 and compare entry counts before and after any conversion, merge or edit. Keep notes of the original input and the output produced by any editor, parser or converter. For larger playlists, entry counts, duplicate counts and metadata-completeness figures provide quick regression checks. If a result changes unexpectedly, return to the smallest known-good sample and reintroduce complexity one step at a time.

M3U Syntax Explained technical checklist

Before considering the job complete, review the following points against the actual use case rather than assuming that successful import in one application proves universal compatibility.

  • The line-oriented model: M3U syntax is line-oriented.
  • The #EXTM3U header: An M3U parser normally reads the file from top to bottom.
  • How #EXTINF is parsed: Extended M3U commonly begins with #EXTM3U.
  • Attribute quoting rules: #EXTINF uses a colon, a duration field, optional attributes and then a comma before the display title.
  • URL and path lines: Attribute values should be quoted, particularly when they contain spaces.
  • Common syntax failures: The line after #EXTINF is typically an absolute URL, but local paths and relative references are possible.

Common questions about M3U Syntax Explained

Does understanding M3U Syntax Explained prove that a stream will work?

No. M3U syntax is line-oriented. Directives and comments begin with #, while media locations appear on ordinary lines. In Extended M3U, an #EXTINF line describes the media location that follows it. Playlist or manifest structure is only one layer. Availability, authorisation, network delivery and decoder support must be tested separately where they apply.

What should I preserve before making changes?

Keep the original text or file, note the player/device used for testing and record any stable identifiers such as tvg-id. For HLS work, keep the original manifest and any relevant child-manifest relationship. A known-good baseline makes rollback and comparison straightforward.

Which M3U.co.uk tool is the best starting point?

For general M3U structure, start with the M3U Checker. Use the Playlist Analyzer for counts and metadata, the M3U Editor for structured changes, and the HLS Inspector when the input contains HLS #EXT-X- directives.

Put it into practice

Inspect or edit your playlist

Use M3U.co.uk’s browser tools. Playlist content is processed locally unless a tool explicitly states otherwise.

Related M3U format guides

M3U.co.uk toolkit

Learn the format. Inspect the playlist. Fix the problem.

Explore free tools