Is there a NPM package that converts language codes like this?

  • en-US => USA
  • ja => JPN
  • pt-BR => BRA

2 Answers 2


You can look at this extensive package, it covers a lot of different variants



npm install i18n-iso-countries
  • It does get country name in a given language, but doesn't provide any language code/name to country code/name conversion.
    – Klaider
    Nov 11, 2020 at 19:49

I've embedded this in my Localization package:

import { Language } from 'com.recoyxgroup.localization';
let {country} = Language('en-US');
country.getName('en-US'); // English (United States)
country.toString(); // en-US

Only specific languages are linked to a Country, so, currently retrieving country from less known languages would result in null. To link a country, the constructor calls at Language.js#L50 just need a second argument (ISO 3166-1 Alpha-3 country code).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.