Registry / serialization / iso639-codes

iso639-codes

JSON →
library1.0.1jsnpmunverified

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.

npm install iso639-codes
INSTALL
IMPORT
SIG · ISO639-CODES
I
iso639-codes
serializationjavascriptv1.0.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

iso
import iso from 'iso639-codes';
import { iso } from 'iso639-codes';
The entire ISO639 language data set is exported as the default export. Do not use named imports.
iso (CommonJS)
const iso = require('iso639-codes');
For CommonJS environments, the entire dataset is returned when requiring the module.
Language Data Access
iso['English']['iso639-1']
iso.English.iso639-1
Language names are string keys, and properties like 'iso639-1' contain hyphens, requiring bracket notation for access.

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}`);
Debug
Known issues
gotchaThe language keys used to access data (e.g., 'Portuguese') are case-sensitive. Using incorrect casing will result in `undefined`.
fix
Ensure the language name matches the key exactly, as found in the dataset (e.g., by inspecting `Object.keys(iso)`). Example: `iso['Portuguese']` is correct, `iso['portuguese']` is not.
affects: >=1.0.0
gotchaThe `iso639-1` property might be `null` for some languages if a two-letter (alpha-2) code does not exist for that language.
fix
Always check for `null` or `undefined` when accessing `iso639-1` (e.g., `language['iso639-1'] ?? 'N/A'`) if the code is optional for your use case.
affects: >=1.0.0
gotchaThe package's data source (www.loc.gov/standards/iso639-2) and the package itself are static. While generally stable, rely on regular updates from the maintainer for the data to reflect the latest ISO standards.
fix
Monitor the package's GitHub repository for updates and ensure your dependencies are kept up-to-date to receive the latest available language data.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'iso639-1')
The language key used to access the `iso` object does not exist, is misspelled, or incorrectly cased.
fix
Ensure the language name matches a key in the `iso` object exactly. Keys are case-sensitive. You can inspect `Object.keys(iso)` to see available language names. Example: `iso['Portuguese']`.
SyntaxError: Named export 'iso' not found
Attempting to use a named import (`import { iso } from 'iso639-codes';`) when the module exports the entire dataset as a default.
fix
Use a default import statement: `import iso from 'iso639-codes';`
ReferenceError: iso is not defined
The `iso` variable was used before it was properly imported or required from the package.
fix
Ensure `const iso = require('iso639-codes');` (for CommonJS) or `import iso from 'iso639-codes';` (for ESM) is at the top of your file before `iso` is referenced.
Upgrade
Version history
1.0.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
6
Resources
iso639-codes — npm install iso639-codes · libregistry