ISO639 Language Codes

1.0.1 · active · verified Sun Apr 19

The `iso639-codes` package provides a comprehensive, static dataset of ISO639 language codes, mapping human-readable language names to their corresponding ISO639-1 (alpha-2) and ISO639-2 (alpha-3) codes, alongside a list of alternative names for each language. The current stable version is 1.0.1, indicating a mature and stable dataset. The package operates on a data-driven release cadence, likely receiving updates primarily when the underlying ISO standard data source (www.loc.gov/standards/iso639-2) changes, or for minor maintenance. Its key differentiator is its direct, pre-parsed JSON structure, which allows for straightforward integration and fast local lookups of language metadata, making it suitable for internationalization (i18n) efforts requiring efficient access to language identifier information without external API calls.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to import the ISO639 language codes dataset and access specific language information by name, including ISO639-1, ISO639-2 codes, and alternative names. It also shows how to iterate through the available languages.

import iso from 'iso639-codes';

// Accessing specific language data by name
console.log(`Portuguese ISO639-1: ${iso['Portuguese']['iso639-1']}`);
console.log(`Portuguese ISO639-2: ${iso['Portuguese']['iso639-2']}`);

// Some languages may not have an ISO639-1 code (returns null)
console.log(`Balinese ISO639-1: ${iso['Balinese']['iso639-1']}`); // Expected: null

// Accessing alternative names for a language
console.log(`Chichewa names: ${iso['Chichewa'].names.join(', ')}`);

// Iterating through the first few languages in the dataset
console.log('\n--- First 3 languages ---');
let count = 0;
for (const langName in iso) {
  if (count >= 3) break;
  const language = iso[langName];
  console.log(`Name: ${language.name}, ISO639-1: ${language['iso639-1'] ?? 'N/A'}, ISO639-2: ${language['iso639-2']}`);
  count++;
}

// Example of looking up a non-existent language (will be undefined)
const nonExistentLang = iso['Klingon'];
console.log(`\nKlingon data: ${nonExistentLang}`);

view raw JSON →