gb‑transit

Tools

Four tools for GB transit data.

One repository, four things you can install. They read the formats the British transport industry actually publishes and write the one everybody else consumes.

1CIF to GTFS

cif2gtfs

Builds the published feed straight from the DTD timetable files. One command, no server, and the same input always produces the same bytes.

2DTD to SQL

dtd2mysql

Imports the fares, routeing guide and timetable feeds into MySQL or MariaDB, downloads them from the DTD server, and converts the timetable to GTFS.

3Bus to GTFS

transxchange2gtfs

Converts TransXChange, the format GB bus and coach timetables are published in, with NaPTAN stop names and coordinates built in.

4Feeds into one

gtfsmerge

Merges GTFS feeds, re-indexing every identifier and generating transfers between stops close enough to walk between.

They are meant to be used together

The rail feed and the bus feed both name a stop by its ATCO code, which is what lets them merge with nothing to reconcile. Three commands is a GTFS feed for the whole of Great Britain, rail and road.

$ npm install -g cif2gtfs transxchange2gtfs gtfsmerge$ cif2gtfs build --source RJTTFxxx.ZIP --out rail.zip$ transxchange2gtfs bus-timetables.zip bus.zip$ gtfsmerge rail.zip bus.zip gb.zip

That merged feed is the one the repository holds to the validator on every change, because the merge renumbers every service, route and trip across two feeds and a dangling reference from that is what a hand-written fixture cannot produce.

Requirements, and where they live

cif2gtfs
apps/cif2gtfs
dtd2mysql
apps/dtd2mysql
transxchange2gtfs
apps/transxchange2gtfs
gtfsmerge
apps/gtfsmerge

All four need Node.js 22 or later, are licensed GPL v3, and are developed in the one repository: planarnetwork/gb-transit. Date handling uses Temporal through a polyfill that hands over to the built-in global on the versions that have one.

You may not need any of them

The feed is already built

If what you want is the British rail timetable as GTFS, it is published every night and you do not have to run anything.

Getting the data

A DTD subscription

The timetable, fares and routeing guide feeds come from the Rail Delivery Group's SFTP server, which needs a subscription from Rail Data Marketplace. NaPTAN and TransXChange data are open and need no account.