Skip to main content
The airline-codes package provides airline data in both CSV (airlines.dat) and JSON (airlines.json) formats. This page documents the structure and fields used throughout the package.

File Formats

The package includes two data files:
FileFormatPurposeSource
airlines.datCSVIntermediate format with corrections appliedOpenFlights.org
airlines.jsonJSONFinal format consumed by the npm packageGenerated from airlines.dat
Most users will interact with airlines.json through the package API. The CSV file is primarily used during the data update pipeline.

JSON Structure

The airlines.json file contains an array of airline objects. Here’s an example:
[
  {
    "id": "24",
    "name": "American Airlines",
    "alias": "",
    "iata": "AA",
    "icao": "AAL",
    "callsign": "AMERICAN",
    "country": "United States",
    "active": "Y"
  },
  {
    "id": "137",
    "name": "Air France",
    "alias": "",
    "iata": "AF",
    "icao": "AFR",
    "callsign": "AIRFRANS",
    "country": "France",
    "active": "Y"
  }
]

Field Definitions

Each airline record contains 8 fields:

id

id
string
required
Unique OpenFlights airline identifier. This ID is stable across updates and used for referencing specific corrections in normalize.js.
Example values: "24", "137", "439"
The ID is stored as a string in JSON for consistency with the CSV format, even though it represents a numeric identifier.

name

name
string
required
Full official name of the airline.
Example values:
  • "American Airlines"
  • "Air France"
  • "Private flight"

alias

alias
string
Alternative name or brand name for the airline. Often empty.
Example values: "", "Aeroflot"
Most airlines don’t have an alias value. This field is preserved from the OpenFlights schema but is rarely populated.

iata

iata
string
Two-character IATA airline designator code. May be empty or contain special values like "-" or "N/A" for airlines without IATA codes.
Example values: "AA", "AF", "DL", "-" Special cases:
  • Empty string: No IATA code assigned
  • "-": Explicitly marked as having no IATA code
  • "N/A": Not applicable (e.g., private flights)
IATA codes are not always unique. Some defunct airlines may share codes with active airlines. The package sorts active airlines first to handle this.

icao

icao
string
Three or four-character ICAO airline designator code. May be empty for airlines without ICAO codes.
Example values: "AAL", "AFR", "DAL", "N/A"

callsign

callsign
string
Radio callsign used by the airline. May be empty.
Example values: "AMERICAN", "AIRFRANS", "DELTA" Callsigns are used in air traffic control communications and may differ from the airline name.

country

country
string
Country where the airline is registered. Uses standardized country names after applying COUNTRY_CORRECTIONS.
Example values:
  • "United States"
  • "South Korea" (not “Republic of Korea”)
  • "Hong Kong"
  • "Russia" (not “Russian Federation”)
Country names are normalized to commonly-recognized names rather than official names. See Data Corrections for the full mapping.

active

active
string
required
Whether the airline is currently operational. Values are "Y" (active) or "N" (inactive).
Values:
  • "Y" - Airline is currently operational
  • "N" - Airline is defunct, merged, or no longer operating
The package sorts active airlines first in airlines.json so that lookups by IATA/ICAO code prioritize active airlines over defunct ones with the same code.

CSV Format

The airlines.dat file uses a simple CSV format without headers:
1,Private flight,,-,N/A,,,Y
24,American Airlines,,AA,AAL,AMERICAN,United States,Y
137,Air France,,AF,AFR,AIRFRANS,France,Y

Column Order

Columns appear in this order:
convert.js:6
var columns = ['id', 'name', 'alias', 'iata', 'icao', 'callsign', 'country', 'active'];
  1. ID
  2. Name
  3. Alias
  4. IATA
  5. ICAO
  6. Callsign
  7. Country
  8. Active
The CSV has no header row. Tools reading the file must know the column positions.

Data Conversion Process

The convert.js script transforms CSV to JSON:
1

Read CSV

Read airlines.dat and parse it with the csv library:
convert.js:8
var content = fs.readFileSync('airlines.dat', 'utf8');
2

Map to Objects

Convert each CSV row to an object using the column names:
convert.js:13-15
var airlines = records.map(function(data) {
  return _.zipObject(columns, data);
});
3

Sort by Active Status

Sort so active airlines appear first:
convert.js:18-19
// Sort active airlines first so they take precedence over inactive ones
airlines = _.sortBy(airlines, function(a) { return a.active === 'Y' ? 0 : 1; });
4

Write JSON

Stream the sorted array to airlines.json:
convert.js:21-25
var writeStream = fs.createWriteStream('airlines.json');
var jsonStream = JSONStream.stringify();
jsonStream.pipe(writeStream);
airlines.forEach(function(a) { jsonStream.write(a); });
The sorting by active status is crucial for lookups. When searching for an airline by IATA code like “AA”, you want the active American Airlines, not a defunct airline that once used that code.

Example Records

Here are some real examples from the data:
{
  "id": "24",
  "name": "American Airlines",
  "alias": "",
  "iata": "AA",
  "icao": "AAL",
  "callsign": "AMERICAN",
  "country": "United States",
  "active": "Y"
}

Data Statistics

The airlines.json file typically contains:
  • ~6,000+ total airline records
  • ~1,000+ active airlines (active: "Y")
  • ~5,000+ inactive airlines (active: "N")
You can check the current statistics:
cat airlines.json | jq '. | length'

Using the Data in Code

The package wraps the JSON in a Backbone Collection for easy querying:
var airlines = require('airline-codes');

// Find by IATA code
airlines.findWhere({ iata: 'AA' });
//=> Returns American Airlines object

// Find by country
airlines.where({ country: 'United States', active: 'Y' });
//=> Returns all active US airlines

// Get raw JSON
airlines.toJSON();
//=> Returns the full array of airline objects
You can also import the JSON directly:
var airlinesData = require('airline-codes/airlines.json');

// Now airlinesData is the raw array
console.log(airlinesData[0]);
See the Basic Usage guide for more examples of working with the data.

Data Source Attribution

All airline data originates from:
This package applies local corrections for standardization but does not claim ownership of the underlying data. All credit goes to the OpenFlights community.

Build docs developers (and LLMs) love