Most people building a first feed learn the individual files before they learn how the files relate. That order is backwards. GTFS trips.txt is the file that ties a route to a day of service, to a path on a map, and to an ordered list of stop times. Many confusing feed errors trace back to that relationship rather than to any single column. This is a guide to the relational core of the General Transit Feed Specification (GTFS): the route, the trip, and the stop_time, and how they represent real service.

Get the hierarchy right and the individual files mostly take care of themselves. Get it wrong and the feed can validate cleanly while still describing service that does not exist.

What Is GTFS trips.txt?

GTFS trips.txt is the file that lists every individual trip a vehicle makes, one row per trip. Each trip belongs to a route, runs on a service calendar, and follows a shape. The trip row links those pieces together and gives the trip an ID that stop_times.txt then attaches an ordered list of timed stops to.

What Is the Difference Between a Route and a Trip?

A route is the named service a rider recognizes: “Route 5” or the “Downtown Loop.” A trip is a single run of that route at a specific time on a specific day. Route 5 is one row in routes.txt. Every departure of Route 5, the 6:15, the 6:45, the 7:15, is a separate row in trips.txt, per the gtfs.org routes reference and the gtfs.org trips reference.

This is the distinction that trips up new producers. A route carries the identity: its short name, long name, color, and type. It carries almost nothing about time or path. All of that lives one level down, on the trips. A rider thinks in routes. The feed thinks in trips. The job of trips.txt is to translate between the two.

Underneath each trip sits stop_times.txt, the largest file in most feeds by a wide margin. One row there is a single stop on a single trip, with an arrival time, a departure time, and a stop_sequence number fixing its order. A trip with 30 stops produces 30 stop_time rows. A route running 40 trips a day across those 30 stops produces 1,200 rows for one route, one day. That volume is why the relational model matters: you never edit those rows by hand, you generate them from a clean route-and-trip structure.

How Do Trips Reference a Service Calendar and a Shape?

Each trip row carries a service_id and a shape_id. The service_id points into calendar.txt (or calendar_dates.txt), which decides the days that trip actually runs. The shape_id points into shapes.txt, which decides the path it draws on a map. Neither lives on the trip itself. The trip only references them.

That indirection is deliberate, and it is where most of the efficiency in a clean feed comes from. A single weekday service_id can be shared by every weekday trip in the system. Extending the schedule by 90 days is then one edit to one calendar row rather than thousands of trip edits. Service calendars without gaps covers how that service_id maps to real days, including the expiry date that silently ends a feed.

The shape_id works the same way. Every trip that follows the same physical path reuses one shape. A route that runs the same road all day needs one shape shared across all its trips, not one shape per departure. Why route geometry matters covers building that geometry from a GPS trace or accumulated vehicle data. And every stop a trip references has to resolve to a real row in the stops file, which is why getting stops.txt right sits directly beneath this whole structure.

Example: one route, three trips Route 5, Downtown routes.txt, route_id r5 trip_id t5_0615 t5_0645 t5_0715 service_id shape_id wkday shp_r5 wkday shp_r5 wkday shp_r5 First stop Main St 06:15 Main St 06:45 Main St 07:15 The same for every trip
One route, many trips, each pointing at a shared calendar and shape

Where Do direction_id, trip_headsign and Route Patterns Belong?

These belong on the trip, not the route, and knowing that resolves a surprising amount of confusion. direction_id is a 0 or 1 flag that separates the two directions of travel: outbound from inbound. It carries no inherent meaning of its own beyond “these trips go one way, those go the other.” Consumers use it to group trips into the two columns riders expect on a timetable.

trip_headsign is the text shown on the front of the vehicle and in a trip planner: “Downtown,” “Airport via Main.” It lives on the trip because it can differ between trips and between the two directions of the same route. A route that reads “Eastbound” on one direction and “Westbound” on the other stores each headsign on its own set of trips.

A route pattern is the specific ordered sequence of stops a group of trips shares. GTFS has no separate pattern file. A pattern is implicit: trips that visit the same stops in the same order, following the same shape, form one pattern. Most agencies have a handful of patterns per route: a full-length pattern and one or two short-turns. Each pattern is just a group of trips that happen to share a stop sequence and a shape.

Why Should You Model Branches as Trips Rather Than Duplicate Routes?

Because a branch is the same rider-facing service taking a different path, not a different service. When Route 5 splits so that some trips serve the hospital and others serve the mall, riders still call all of it Route 5. The right model is one route with two trip patterns: hospital trips reference one shape and stop sequence, mall trips reference another. Both keep the same route_id.

Duplicating the route instead, creating “Route 5A” and “Route 5B” as separate routes.txt rows, is the common mistake. It splits one recognizable service into two entries in a trip planner, doubles the maintenance surface, and confuses a rider who has only ever seen “Route 5” on the bus. The branches were never separate routes operationally. They should not be separate routes in the data. Model the variation where variation actually lives, on the trips.

How Does This Structure Feed Downstream Into GTFS-Realtime Trip Updates?

The static trip is the anchor for everything real-time. A GTFS-Realtime (GTFS-RT) trip update references a trip_id straight out of trips.txt to say a specific run is now three minutes late or cancelled. If the trip does not exist in the static feed, the real-time message has nothing to attach to and consumers drop it.

This is why the relational model is not just a static-feed concern. GTFS-RT vehicle positions and trip updates depend on stable, correct trip_id values that match the schedule a consumer already loaded. A feed with unstable or duplicated trip IDs breaks real-time matching quietly, the same way a recycled stop ID breaks a cached reference. GTFS-Realtime, explained covers how the two feeds stay linked. For agencies with turn-up-and-go service, GTFS frequencies.txt offers a different way to represent trips, and GTFS transfers.txt shows how those trips connect to one another at a hub.

FAQ

Is a Route or a Trip the Bigger Unit in GTFS?

A route is the bigger unit. One route contains many trips. The route is the named service riders recognize, and each trip is a single timed run of that service on a specific day. Routes live in routes.txt, trips live in trips.txt, and every trip references exactly one route through its route_id.

Do I Need a Separate Route for Each Direction of Travel?

No. Both directions belong to the same route. The direction_id field on each trip, set to 0 or 1, separates outbound from inbound. Splitting a two-way route into two routes duplicates the service in trip planners and doubles maintenance for no benefit.

stop_times.txt links them. Each row there references a trip_id and a stop_id, carries an arrival and departure time, and uses stop_sequence to fix the order of stops along the trip. One trip with 30 stops produces 30 stop_time rows.

Should Route Branches Be Separate Routes?

No. A branch is the same route taking a different path for some trips. Model it as trips with their own shape and stop sequence under one shared route_id, not as a duplicate route. Riders see one service; the feed should describe one service.

Where TransitFare Fits

TransitFare is a transit technology company founded in 2012 that builds standalone GTFS publishing tools for small and mid-sized transit agencies, from fleets of 10 vehicles to fleets of 50 vehicles. TransitFare Cloud generates the route, trip, and stop_time hierarchy directly from scheduling data. Branches become trip patterns and directions become direction_id values without hand-editing thousands of rows. With 60 million+ fare validations processed and a strong production reliability record across 13+ years of operation, it produces complex schedules, interlining, and holiday service as a clean relational feed. See GTFS publishing in TransitFare Cloud, read how GTFS is automated from scheduling software, or start with the GTFS guide for the full standard.