Instantly share code, notes, and snippets.

Embed
What would you like to do?
ISO 3166-1 alpha-2 country code to country name conversion with a simple Javascript implementation, an array and a function.
var isoCountries = {
'AF' : 'Afghanistan',
'AX' : 'Aland Islands',
'AL' : 'Albania',
'DZ' : 'Algeria',
'AS' : 'American Samoa',
'AD' : 'Andorra',
'AO' : 'Angola',
'AI' : 'Anguilla',
'AQ' : 'Antarctica',
'AG' : 'Antigua And Barbuda',
'AR' : 'Argentina',
'AM' : 'Armenia',
'AW' : 'Aruba',
'AU' : 'Australia',
'AT' : 'Austria',
'AZ' : 'Azerbaijan',
'BS' : 'Bahamas',
'BH' : 'Bahrain',
'BD' : 'Bangladesh',
'BB' : 'Barbados',
'BY' : 'Belarus',
'BE' : 'Belgium',
'BZ' : 'Belize',
'BJ' : 'Benin',
'BM' : 'Bermuda',
'BT' : 'Bhutan',
'BO' : 'Bolivia',
'BA' : 'Bosnia And Herzegovina',
'BW' : 'Botswana',
'BV' : 'Bouvet Island',
'BR' : 'Brazil',
'IO' : 'British Indian Ocean Territory',
'BN' : 'Brunei Darussalam',
'BG' : 'Bulgaria',
'BF' : 'Burkina Faso',
'BI' : 'Burundi',
'KH' : 'Cambodia',
'CM' : 'Cameroon',
'CA' : 'Canada',
'CV' : 'Cape Verde',
'KY' : 'Cayman Islands',
'CF' : 'Central African Republic',
'TD' : 'Chad',
'CL' : 'Chile',
'CN' : 'China',
'CX' : 'Christmas Island',
'CC' : 'Cocos (Keeling) Islands',
'CO' : 'Colombia',
'KM' : 'Comoros',
'CG' : 'Congo',
'CD' : 'Congo, Democratic Republic',
'CK' : 'Cook Islands',
'CR' : 'Costa Rica',
'CI' : 'Cote D\'Ivoire',
'HR' : 'Croatia',
'CU' : 'Cuba',
'CY' : 'Cyprus',
'CZ' : 'Czech Republic',
'DK' : 'Denmark',
'DJ' : 'Djibouti',
'DM' : 'Dominica',
'DO' : 'Dominican Republic',
'EC' : 'Ecuador',
'EG' : 'Egypt',
'SV' : 'El Salvador',
'GQ' : 'Equatorial Guinea',
'ER' : 'Eritrea',
'EE' : 'Estonia',
'ET' : 'Ethiopia',
'FK' : 'Falkland Islands (Malvinas)',
'FO' : 'Faroe Islands',
'FJ' : 'Fiji',
'FI' : 'Finland',
'FR' : 'France',
'GF' : 'French Guiana',
'PF' : 'French Polynesia',
'TF' : 'French Southern Territories',
'GA' : 'Gabon',
'GM' : 'Gambia',
'GE' : 'Georgia',
'DE' : 'Germany',
'GH' : 'Ghana',
'GI' : 'Gibraltar',
'GR' : 'Greece',
'GL' : 'Greenland',
'GD' : 'Grenada',
'GP' : 'Guadeloupe',
'GU' : 'Guam',
'GT' : 'Guatemala',
'GG' : 'Guernsey',
'GN' : 'Guinea',
'GW' : 'Guinea-Bissau',
'GY' : 'Guyana',
'HT' : 'Haiti',
'HM' : 'Heard Island & Mcdonald Islands',
'VA' : 'Holy See (Vatican City State)',
'HN' : 'Honduras',
'HK' : 'Hong Kong',
'HU' : 'Hungary',
'IS' : 'Iceland',
'IN' : 'India',
'ID' : 'Indonesia',
'IR' : 'Iran, Islamic Republic Of',
'IQ' : 'Iraq',
'IE' : 'Ireland',
'IM' : 'Isle Of Man',
'IL' : 'Israel',
'IT' : 'Italy',
'JM' : 'Jamaica',
'JP' : 'Japan',
'JE' : 'Jersey',
'JO' : 'Jordan',
'KZ' : 'Kazakhstan',
'KE' : 'Kenya',
'KI' : 'Kiribati',
'KR' : 'Korea',
'KW' : 'Kuwait',
'KG' : 'Kyrgyzstan',
'LA' : 'Lao People\'s Democratic Republic',
'LV' : 'Latvia',
'LB' : 'Lebanon',
'LS' : 'Lesotho',
'LR' : 'Liberia',
'LY' : 'Libyan Arab Jamahiriya',
'LI' : 'Liechtenstein',
'LT' : 'Lithuania',
'LU' : 'Luxembourg',
'MO' : 'Macao',
'MK' : 'Macedonia',
'MG' : 'Madagascar',
'MW' : 'Malawi',
'MY' : 'Malaysia',
'MV' : 'Maldives',
'ML' : 'Mali',
'MT' : 'Malta',
'MH' : 'Marshall Islands',
'MQ' : 'Martinique',
'MR' : 'Mauritania',
'MU' : 'Mauritius',
'YT' : 'Mayotte',
'MX' : 'Mexico',
'FM' : 'Micronesia, Federated States Of',
'MD' : 'Moldova',
'MC' : 'Monaco',
'MN' : 'Mongolia',
'ME' : 'Montenegro',
'MS' : 'Montserrat',
'MA' : 'Morocco',
'MZ' : 'Mozambique',
'MM' : 'Myanmar',
'NA' : 'Namibia',
'NR' : 'Nauru',
'NP' : 'Nepal',
'NL' : 'Netherlands',
'AN' : 'Netherlands Antilles',
'NC' : 'New Caledonia',
'NZ' : 'New Zealand',
'NI' : 'Nicaragua',
'NE' : 'Niger',
'NG' : 'Nigeria',
'NU' : 'Niue',
'NF' : 'Norfolk Island',
'MP' : 'Northern Mariana Islands',
'NO' : 'Norway',
'OM' : 'Oman',
'PK' : 'Pakistan',
'PW' : 'Palau',
'PS' : 'Palestinian Territory, Occupied',
'PA' : 'Panama',
'PG' : 'Papua New Guinea',
'PY' : 'Paraguay',
'PE' : 'Peru',
'PH' : 'Philippines',
'PN' : 'Pitcairn',
'PL' : 'Poland',
'PT' : 'Portugal',
'PR' : 'Puerto Rico',
'QA' : 'Qatar',
'RE' : 'Reunion',
'RO' : 'Romania',
'RU' : 'Russian Federation',
'RW' : 'Rwanda',
'BL' : 'Saint Barthelemy',
'SH' : 'Saint Helena',
'KN' : 'Saint Kitts And Nevis',
'LC' : 'Saint Lucia',
'MF' : 'Saint Martin',
'PM' : 'Saint Pierre And Miquelon',
'VC' : 'Saint Vincent And Grenadines',
'WS' : 'Samoa',
'SM' : 'San Marino',
'ST' : 'Sao Tome And Principe',
'SA' : 'Saudi Arabia',
'SN' : 'Senegal',
'RS' : 'Serbia',
'SC' : 'Seychelles',
'SL' : 'Sierra Leone',
'SG' : 'Singapore',
'SK' : 'Slovakia',
'SI' : 'Slovenia',
'SB' : 'Solomon Islands',
'SO' : 'Somalia',
'ZA' : 'South Africa',
'GS' : 'South Georgia And Sandwich Isl.',
'ES' : 'Spain',
'LK' : 'Sri Lanka',
'SD' : 'Sudan',
'SR' : 'Suriname',
'SJ' : 'Svalbard And Jan Mayen',
'SZ' : 'Swaziland',
'SE' : 'Sweden',
'CH' : 'Switzerland',
'SY' : 'Syrian Arab Republic',
'TW' : 'Taiwan',
'TJ' : 'Tajikistan',
'TZ' : 'Tanzania',
'TH' : 'Thailand',
'TL' : 'Timor-Leste',
'TG' : 'Togo',
'TK' : 'Tokelau',
'TO' : 'Tonga',
'TT' : 'Trinidad And Tobago',
'TN' : 'Tunisia',
'TR' : 'Turkey',
'TM' : 'Turkmenistan',
'TC' : 'Turks And Caicos Islands',
'TV' : 'Tuvalu',
'UG' : 'Uganda',
'UA' : 'Ukraine',
'AE' : 'United Arab Emirates',
'GB' : 'United Kingdom',
'US' : 'United States',
'UM' : 'United States Outlying Islands',
'UY' : 'Uruguay',
'UZ' : 'Uzbekistan',
'VU' : 'Vanuatu',
'VE' : 'Venezuela',
'VN' : 'Viet Nam',
'VG' : 'Virgin Islands, British',
'VI' : 'Virgin Islands, U.S.',
'WF' : 'Wallis And Futuna',
'EH' : 'Western Sahara',
'YE' : 'Yemen',
'ZM' : 'Zambia',
'ZW' : 'Zimbabwe'
};
function getCountryName (countryCode) {
if (isoCountries.hasOwnProperty(countryCode)) {
return isoCountries[countryCode];
} else {
return countryCode;
}
}
@klagithub1

This comment has been minimized.

Show comment
Hide comment
@klagithub1

klagithub1 commented May 3, 2015

thx !

@4gus71n

This comment has been minimized.

Show comment
Hide comment
@4gus71n

4gus71n commented May 20, 2015

Thanks!

@zenvarlab

This comment has been minimized.

Show comment
Hide comment
@zenvarlab

zenvarlab Jun 3, 2015

many thanks I fork it

zenvarlab commented Jun 3, 2015

many thanks I fork it

@mustbebuilt

This comment has been minimized.

Show comment
Hide comment
@mustbebuilt

mustbebuilt Jun 11, 2015

For anyone using knockout.js try:

<select data-bind="options: availableCountries, optionsText: 'cname', optionsValue: 'ccode'">

</select>



<script src="../js/knockout-3.3.0.js"></script>
<script>
var isoCountries = [
    {'ccode' : 'AF', 'cname' : 'Afghanistan'},
    {'ccode' : 'AX', 'cname' : 'Aland Islands'},
    {'ccode' : 'AL', 'cname' : 'Albania'},
    {'ccode' : 'DZ', 'cname' : 'Algeria'},
    {'ccode' : 'AS', 'cname' : 'American Samoa'},
    {'ccode' : 'AD', 'cname' : 'Andorra'},
    {'ccode' : 'AO', 'cname' : 'Angola'},
    {'ccode' : 'AI', 'cname' : 'Anguilla'},
    {'ccode' : 'AQ', 'cname' : 'Antarctica'},
    {'ccode' : 'AG', 'cname' : 'Antigua And Barbuda'},
    {'ccode' : 'AR', 'cname' : 'Argentina'},
    {'ccode' : 'AM', 'cname' : 'Armenia'},
    {'ccode' : 'AW', 'cname' : 'Aruba'},
    {'ccode' : 'AU', 'cname' : 'Australia'},
    {'ccode' : 'AT', 'cname' : 'Austria'},
    {'ccode' : 'AZ', 'cname' : 'Azerbaijan'},
    {'ccode' : 'BS', 'cname' : 'Bahamas'},
    {'ccode' : 'BH', 'cname' : 'Bahrain'},
    {'ccode' : 'BD', 'cname' : 'Bangladesh'},
    {'ccode' : 'BB', 'cname' : 'Barbados'},
    {'ccode' : 'BY', 'cname' : 'Belarus'},
    {'ccode' : 'BE', 'cname' : 'Belgium'},
    {'ccode' : 'BZ', 'cname' : 'Belize'},
    {'ccode' : 'BJ', 'cname' : 'Benin'},
    {'ccode' : 'BM', 'cname' : 'Bermuda'},
    {'ccode' : 'BT', 'cname' : 'Bhutan'},
    {'ccode' : 'BO', 'cname' : 'Bolivia'},
    {'ccode' : 'BA', 'cname' : 'Bosnia And Herzegovina'},
    {'ccode' : 'BW', 'cname' : 'Botswana'},
    {'ccode' : 'BV', 'cname' : 'Bouvet Island'},
    {'ccode' : 'BR', 'cname' : 'Brazil'},
    {'ccode' : 'IO', 'cname' : 'British Indian Ocean Territory'},
    {'ccode' : 'BN', 'cname' : 'Brunei Darussalam'},
    {'ccode' : 'BG', 'cname' : 'Bulgaria'},
    {'ccode' : 'BF', 'cname' : 'Burkina Faso'},
    {'ccode' : 'BI', 'cname' : 'Burundi'},
    {'ccode' : 'KH', 'cname' : 'Cambodia'},
    {'ccode' : 'CM', 'cname' : 'Cameroon'},
    {'ccode' : 'CA', 'cname' : 'Canada'},
    {'ccode' : 'CV', 'cname' : 'Cape Verde'},
    {'ccode' : 'KY', 'cname' : 'Cayman Islands'},
    {'ccode' : 'CF', 'cname' : 'Central African Republic'},
    {'ccode' : 'TD', 'cname' : 'Chad'},
    {'ccode' : 'CL', 'cname' : 'Chile'},
    {'ccode' : 'CN', 'cname' : 'China'},
    {'ccode' : 'CX', 'cname' : 'Christmas Island'},
    {'ccode' : 'CC', 'cname' : 'Cocos (Keeling) Islands'},
    {'ccode' : 'CO', 'cname' : 'Colombia'},
    {'ccode' : 'KM', 'cname' : 'Comoros'},
    {'ccode' : 'CG', 'cname' : 'Congo'},
    {'ccode' : 'CD', 'cname' : 'Congo, Democratic Republic'},
    {'ccode' : 'CK', 'cname' : 'Cook Islands'},
    {'ccode' : 'CR', 'cname' : 'Costa Rica'},
    {'ccode' : 'CI', 'cname' : 'Cote D\'Ivoire'},
    {'ccode' : 'HR', 'cname' : 'Croatia'},
    {'ccode' : 'CU', 'cname' : 'Cuba'},
    {'ccode' : 'CY', 'cname' : 'Cyprus'},
    {'ccode' : 'CZ', 'cname' : 'Czech Republic'},
    {'ccode' : 'DK', 'cname' : 'Denmark'},
    {'ccode' : 'DJ', 'cname' : 'Djibouti'},
    {'ccode' : 'DM', 'cname' : 'Dominica'},
    {'ccode' : 'DO', 'cname' : 'Dominican Republic'},
    {'ccode' : 'EC', 'cname' : 'Ecuador'},
    {'ccode' : 'EG', 'cname' : 'Egypt'},
    {'ccode' : 'SV', 'cname' : 'El Salvador'},
    {'ccode' : 'GQ', 'cname' : 'Equatorial Guinea'},
    {'ccode' : 'ER', 'cname' : 'Eritrea'},
    {'ccode' : 'EE', 'cname' : 'Estonia'},
    {'ccode' : 'ET', 'cname' : 'Ethiopia'},
    {'ccode' : 'FK', 'cname' : 'Falkland Islands (Malvinas)'},
    {'ccode' : 'FO', 'cname' : 'Faroe Islands'},
    {'ccode' : 'FJ', 'cname' : 'Fiji'},
    {'ccode' : 'FI', 'cname' : 'Finland'},
    {'ccode' : 'FR', 'cname' : 'France'},
    {'ccode' : 'GF', 'cname' : 'French Guiana'},
    {'ccode' : 'PF', 'cname' : 'French Polynesia'},
    {'ccode' : 'TF', 'cname' : 'French Southern Territories'},
    {'ccode' : 'GA', 'cname' : 'Gabon'},
    {'ccode' : 'GM', 'cname' : 'Gambia'},
    {'ccode' : 'GE', 'cname' : 'Georgia'},
    {'ccode' : 'DE', 'cname' : 'Germany'},
    {'ccode' : 'GH', 'cname' : 'Ghana'},
    {'ccode' : 'GI', 'cname' : 'Gibraltar'},
    {'ccode' : 'GR', 'cname' : 'Greece'},
    {'ccode' : 'GL', 'cname' : 'Greenland'},
    {'ccode' : 'GD', 'cname' : 'Grenada'},
    {'ccode' : 'GP', 'cname' : 'Guadeloupe'},
    {'ccode' : 'GU', 'cname' : 'Guam'},
    {'ccode' : 'GT', 'cname' : 'Guatemala'},
    {'ccode' : 'GG', 'cname' : 'Guernsey'},
    {'ccode' : 'GN', 'cname' : 'Guinea'},
    {'ccode' : 'GW', 'cname' : 'Guinea-Bissau'},
    {'ccode' : 'GY', 'cname' : 'Guyana'},
    {'ccode' : 'HT', 'cname' : 'Haiti'},
    {'ccode' : 'HM', 'cname' : 'Heard Island & Mcdonald Islands'},
    {'ccode' : 'VA', 'cname' : 'Holy See (Vatican City State)'},
    {'ccode' : 'HN', 'cname' : 'Honduras'},
    {'ccode' : 'HK', 'cname' : 'Hong Kong'},
    {'ccode' : 'HU', 'cname' : 'Hungary'},
    {'ccode' : 'IS', 'cname' : 'Iceland'},
    {'ccode' : 'IN', 'cname' : 'India'},
    {'ccode' : 'ID', 'cname' : 'Indonesia'},
    {'ccode' : 'IR', 'cname' : 'Iran, Islamic Republic Of'},
    {'ccode' : 'IQ', 'cname' : 'Iraq'},
    {'ccode' : 'IE', 'cname' : 'Ireland'},
    {'ccode' : 'IM', 'cname' : 'Isle Of Man'},
    {'ccode' : 'IL', 'cname' : 'Israel'},
    {'ccode' : 'IT', 'cname' : 'Italy'},
    {'ccode' : 'JM', 'cname' : 'Jamaica'},
    {'ccode' : 'JP', 'cname' : 'Japan'},
    {'ccode' : 'JE', 'cname' : 'Jersey'},
    {'ccode' : 'JO', 'cname' : 'Jordan'},
    {'ccode' : 'KZ', 'cname' : 'Kazakhstan'},
    {'ccode' : 'KE', 'cname' : 'Kenya'},
    {'ccode' : 'KI', 'cname' : 'Kiribati'},
    {'ccode' : 'KR', 'cname' : 'Korea'},
    {'ccode' : 'KW', 'cname' : 'Kuwait'},
    {'ccode' : 'KG', 'cname' : 'Kyrgyzstan'},
    {'ccode' : 'LA', 'cname' : 'Lao People\'s Democratic Republic'},
    {'ccode' : 'LV', 'cname' : 'Latvia'},
    {'ccode' : 'LB', 'cname' : 'Lebanon'},
    {'ccode' : 'LS', 'cname' : 'Lesotho'},
    {'ccode' : 'LR', 'cname' : 'Liberia'},
    {'ccode' : 'LY', 'cname' : 'Libyan Arab Jamahiriya'},
    {'ccode' : 'LI', 'cname' : 'Liechtenstein'},
    {'ccode' : 'LT', 'cname' : 'Lithuania'},
    {'ccode' : 'LU', 'cname' : 'Luxembourg'},
    {'ccode' : 'MO', 'cname' : 'Macao'},
    {'ccode' : 'MK', 'cname' : 'Macedonia'},
    {'ccode' : 'MG', 'cname' : 'Madagascar'},
    {'ccode' : 'MW', 'cname' : 'Malawi'},
    {'ccode' : 'MY', 'cname' : 'Malaysia'},
    {'ccode' : 'MV', 'cname' : 'Maldives'},
    {'ccode' : 'ML', 'cname' : 'Mali'},
    {'ccode' : 'MT', 'cname' : 'Malta'},
    {'ccode' : 'MH', 'cname' : 'Marshall Islands'},
    {'ccode' : 'MQ', 'cname' : 'Martinique'},
    {'ccode' : 'MR', 'cname' : 'Mauritania'},
    {'ccode' : 'MU', 'cname' : 'Mauritius'},
    {'ccode' : 'YT', 'cname' : 'Mayotte'},
    {'ccode' : 'MX', 'cname' : 'Mexico'},
    {'ccode' : 'FM', 'cname' : 'Micronesia, Federated States Of'},
    {'ccode' : 'MD', 'cname' : 'Moldova'},
    {'ccode' : 'MC', 'cname' : 'Monaco'},
    {'ccode' : 'MN', 'cname' : 'Mongolia'},
    {'ccode' : 'ME', 'cname' : 'Montenegro'},
    {'ccode' : 'MS', 'cname' : 'Montserrat'},
    {'ccode' : 'MA', 'cname' : 'Morocco'},
    {'ccode' : 'MZ', 'cname' : 'Mozambique'},
    {'ccode' : 'MM', 'cname' : 'Myanmar'},
    {'ccode' : 'NA', 'cname' : 'Namibia'},
    {'ccode' : 'NR', 'cname' : 'Nauru'},
    {'ccode' : 'NP', 'cname' : 'Nepal'},
    {'ccode' : 'NL', 'cname' : 'Netherlands'},
    {'ccode' : 'AN', 'cname' : 'Netherlands Antilles'},
    {'ccode' : 'NC', 'cname' : 'New Caledonia'},
    {'ccode' : 'NZ', 'cname' : 'New Zealand'},
    {'ccode' : 'NI', 'cname' : 'Nicaragua'},
    {'ccode' : 'NE', 'cname' : 'Niger'},
    {'ccode' : 'NG', 'cname' : 'Nigeria'},
    {'ccode' : 'NU', 'cname' : 'Niue'},
    {'ccode' : 'NF', 'cname' : 'Norfolk Island'},
    {'ccode' : 'MP', 'cname' : 'Northern Mariana Islands'},
    {'ccode' : 'NO', 'cname' : 'Norway'},
    {'ccode' : 'OM', 'cname' : 'Oman'},
    {'ccode' : 'PK', 'cname' : 'Pakistan'},
    {'ccode' : 'PW', 'cname' : 'Palau'},
    {'ccode' : 'PS', 'cname' : 'Palestinian Territory, Occupied'},
    {'ccode' : 'PA', 'cname' : 'Panama'},
    {'ccode' : 'PG', 'cname' : 'Papua New Guinea'},
    {'ccode' : 'PY', 'cname' : 'Paraguay'},
    {'ccode' : 'PE', 'cname' : 'Peru'},
    {'ccode' : 'PH', 'cname' : 'Philippines'},
    {'ccode' : 'PN', 'cname' : 'Pitcairn'},
    {'ccode' : 'PL', 'cname' : 'Poland'},
    {'ccode' : 'PT', 'cname' : 'Portugal'},
    {'ccode' : 'PR', 'cname' : 'Puerto Rico'},
    {'ccode' : 'QA', 'cname' : 'Qatar'},
    {'ccode' : 'RE', 'cname' : 'Reunion'},
    {'ccode' : 'RO', 'cname' : 'Romania'},
    {'ccode' : 'RU', 'cname' : 'Russian Federation'},
    {'ccode' : 'RW', 'cname' : 'Rwanda'},
    {'ccode' : 'BL', 'cname' : 'Saint Barthelemy'},
    {'ccode' : 'SH', 'cname' : 'Saint Helena'},
    {'ccode' : 'KN', 'cname' : 'Saint Kitts And Nevis'},
    {'ccode' : 'LC', 'cname' : 'Saint Lucia'},
    {'ccode' : 'MF', 'cname' : 'Saint Martin'},
    {'ccode' : 'PM', 'cname' : 'Saint Pierre And Miquelon'},
    {'ccode' : 'VC', 'cname' : 'Saint Vincent And Grenadines'},
    {'ccode' : 'WS', 'cname' : 'Samoa'},
    {'ccode' : 'SM', 'cname' : 'San Marino'},
    {'ccode' : 'ST', 'cname' : 'Sao Tome And Principe'},
    {'ccode' : 'SA', 'cname' : 'Saudi Arabia'},
    {'ccode' : 'SN', 'cname' : 'Senegal'},
    {'ccode' : 'RS', 'cname' : 'Serbia'},
    {'ccode' : 'SC', 'cname' : 'Seychelles'},
    {'ccode' : 'SL', 'cname' : 'Sierra Leone'},
    {'ccode' : 'SG', 'cname' : 'Singapore'},
    {'ccode' : 'SK', 'cname' : 'Slovakia'},
    {'ccode' : 'SI', 'cname' : 'Slovenia'},
    {'ccode' : 'SB', 'cname' : 'Solomon Islands'},
    {'ccode' : 'SO', 'cname' : 'Somalia'},
    {'ccode' : 'ZA', 'cname' : 'South Africa'},
    {'ccode' : 'GS', 'cname' : 'South Georgia And Sandwich Isl.'},
    {'ccode' : 'ES', 'cname' : 'Spain'},
    {'ccode' : 'LK', 'cname' : 'Sri Lanka'},
    {'ccode' : 'SD', 'cname' : 'Sudan'},
    {'ccode' : 'SR', 'cname' : 'Suriname'},
    {'ccode' : 'SJ', 'cname' : 'Svalbard And Jan Mayen'},
    {'ccode' : 'SZ', 'cname' : 'Swaziland'},
    {'ccode' : 'SE', 'cname' : 'Sweden'},
    {'ccode' : 'CH', 'cname' : 'Switzerland'},
    {'ccode' : 'SY', 'cname' : 'Syrian Arab Republic'},
    {'ccode' : 'TW', 'cname' : 'Taiwan'},
    {'ccode' : 'TJ', 'cname' : 'Tajikistan'},
    {'ccode' : 'TZ', 'cname' : 'Tanzania'},
    {'ccode' : 'TH', 'cname' : 'Thailand'},
    {'ccode' : 'TL', 'cname' : 'Timor-Leste'},
    {'ccode' : 'TG', 'cname' : 'Togo'},
    {'ccode' : 'TK', 'cname' : 'Tokelau'},
    {'ccode' : 'TO', 'cname' : 'Tonga'},
    {'ccode' : 'TT', 'cname' : 'Trinidad And Tobago'},
    {'ccode' : 'TN', 'cname' : 'Tunisia'},
    {'ccode' : 'TR', 'cname' : 'Turkey'},
    {'ccode' : 'TM', 'cname' : 'Turkmenistan'},
    {'ccode' : 'TC', 'cname' : 'Turks And Caicos Islands'},
    {'ccode' : 'TV', 'cname' : 'Tuvalu'},
    {'ccode' : 'UG', 'cname' : 'Uganda'},
    {'ccode' : 'UA', 'cname' : 'Ukraine'},
    {'ccode' : 'AE', 'cname' : 'United Arab Emirates'},
    {'ccode' : 'GB', 'cname' : 'United Kingdom'},
    {'ccode' : 'US', 'cname' : 'United States'},
    {'ccode' : 'UM', 'cname' : 'United States Outlying Islands'},
    {'ccode' : 'UY', 'cname' : 'Uruguay'},
    {'ccode' : 'UZ', 'cname' : 'Uzbekistan'},
    {'ccode' : 'VU', 'cname' : 'Vanuatu'},
    {'ccode' : 'VE', 'cname' : 'Venezuela'},
    {'ccode' : 'VN', 'cname' : 'Viet Nam'},
    {'ccode' : 'VG', 'cname' : 'Virgin Islands, British'},
    {'ccode' : 'VI', 'cname' : 'Virgin Islands, U.S.'},
    {'ccode' : 'WF', 'cname' : 'Wallis And Futuna'},
    {'ccode' : 'EH', 'cname' : 'Western Sahara'},
    {'ccode' : 'YE', 'cname' : 'Yemen'},
    {'ccode' : 'ZM', 'cname' : 'Zambia'},
    {'ccode' : 'ZW', 'cname' : 'Zimbabwe'}
];

function CountryModel() {
    var self = this;
    self.availableCountries = ko.observableArray(isoCountries);
}

ko.applyBindings(new CountryModel());

mustbebuilt commented Jun 11, 2015

For anyone using knockout.js try:

<select data-bind="options: availableCountries, optionsText: 'cname', optionsValue: 'ccode'">

</select>



<script src="../js/knockout-3.3.0.js"></script>
<script>
var isoCountries = [
    {'ccode' : 'AF', 'cname' : 'Afghanistan'},
    {'ccode' : 'AX', 'cname' : 'Aland Islands'},
    {'ccode' : 'AL', 'cname' : 'Albania'},
    {'ccode' : 'DZ', 'cname' : 'Algeria'},
    {'ccode' : 'AS', 'cname' : 'American Samoa'},
    {'ccode' : 'AD', 'cname' : 'Andorra'},
    {'ccode' : 'AO', 'cname' : 'Angola'},
    {'ccode' : 'AI', 'cname' : 'Anguilla'},
    {'ccode' : 'AQ', 'cname' : 'Antarctica'},
    {'ccode' : 'AG', 'cname' : 'Antigua And Barbuda'},
    {'ccode' : 'AR', 'cname' : 'Argentina'},
    {'ccode' : 'AM', 'cname' : 'Armenia'},
    {'ccode' : 'AW', 'cname' : 'Aruba'},
    {'ccode' : 'AU', 'cname' : 'Australia'},
    {'ccode' : 'AT', 'cname' : 'Austria'},
    {'ccode' : 'AZ', 'cname' : 'Azerbaijan'},
    {'ccode' : 'BS', 'cname' : 'Bahamas'},
    {'ccode' : 'BH', 'cname' : 'Bahrain'},
    {'ccode' : 'BD', 'cname' : 'Bangladesh'},
    {'ccode' : 'BB', 'cname' : 'Barbados'},
    {'ccode' : 'BY', 'cname' : 'Belarus'},
    {'ccode' : 'BE', 'cname' : 'Belgium'},
    {'ccode' : 'BZ', 'cname' : 'Belize'},
    {'ccode' : 'BJ', 'cname' : 'Benin'},
    {'ccode' : 'BM', 'cname' : 'Bermuda'},
    {'ccode' : 'BT', 'cname' : 'Bhutan'},
    {'ccode' : 'BO', 'cname' : 'Bolivia'},
    {'ccode' : 'BA', 'cname' : 'Bosnia And Herzegovina'},
    {'ccode' : 'BW', 'cname' : 'Botswana'},
    {'ccode' : 'BV', 'cname' : 'Bouvet Island'},
    {'ccode' : 'BR', 'cname' : 'Brazil'},
    {'ccode' : 'IO', 'cname' : 'British Indian Ocean Territory'},
    {'ccode' : 'BN', 'cname' : 'Brunei Darussalam'},
    {'ccode' : 'BG', 'cname' : 'Bulgaria'},
    {'ccode' : 'BF', 'cname' : 'Burkina Faso'},
    {'ccode' : 'BI', 'cname' : 'Burundi'},
    {'ccode' : 'KH', 'cname' : 'Cambodia'},
    {'ccode' : 'CM', 'cname' : 'Cameroon'},
    {'ccode' : 'CA', 'cname' : 'Canada'},
    {'ccode' : 'CV', 'cname' : 'Cape Verde'},
    {'ccode' : 'KY', 'cname' : 'Cayman Islands'},
    {'ccode' : 'CF', 'cname' : 'Central African Republic'},
    {'ccode' : 'TD', 'cname' : 'Chad'},
    {'ccode' : 'CL', 'cname' : 'Chile'},
    {'ccode' : 'CN', 'cname' : 'China'},
    {'ccode' : 'CX', 'cname' : 'Christmas Island'},
    {'ccode' : 'CC', 'cname' : 'Cocos (Keeling) Islands'},
    {'ccode' : 'CO', 'cname' : 'Colombia'},
    {'ccode' : 'KM', 'cname' : 'Comoros'},
    {'ccode' : 'CG', 'cname' : 'Congo'},
    {'ccode' : 'CD', 'cname' : 'Congo, Democratic Republic'},
    {'ccode' : 'CK', 'cname' : 'Cook Islands'},
    {'ccode' : 'CR', 'cname' : 'Costa Rica'},
    {'ccode' : 'CI', 'cname' : 'Cote D\'Ivoire'},
    {'ccode' : 'HR', 'cname' : 'Croatia'},
    {'ccode' : 'CU', 'cname' : 'Cuba'},
    {'ccode' : 'CY', 'cname' : 'Cyprus'},
    {'ccode' : 'CZ', 'cname' : 'Czech Republic'},
    {'ccode' : 'DK', 'cname' : 'Denmark'},
    {'ccode' : 'DJ', 'cname' : 'Djibouti'},
    {'ccode' : 'DM', 'cname' : 'Dominica'},
    {'ccode' : 'DO', 'cname' : 'Dominican Republic'},
    {'ccode' : 'EC', 'cname' : 'Ecuador'},
    {'ccode' : 'EG', 'cname' : 'Egypt'},
    {'ccode' : 'SV', 'cname' : 'El Salvador'},
    {'ccode' : 'GQ', 'cname' : 'Equatorial Guinea'},
    {'ccode' : 'ER', 'cname' : 'Eritrea'},
    {'ccode' : 'EE', 'cname' : 'Estonia'},
    {'ccode' : 'ET', 'cname' : 'Ethiopia'},
    {'ccode' : 'FK', 'cname' : 'Falkland Islands (Malvinas)'},
    {'ccode' : 'FO', 'cname' : 'Faroe Islands'},
    {'ccode' : 'FJ', 'cname' : 'Fiji'},
    {'ccode' : 'FI', 'cname' : 'Finland'},
    {'ccode' : 'FR', 'cname' : 'France'},
    {'ccode' : 'GF', 'cname' : 'French Guiana'},
    {'ccode' : 'PF', 'cname' : 'French Polynesia'},
    {'ccode' : 'TF', 'cname' : 'French Southern Territories'},
    {'ccode' : 'GA', 'cname' : 'Gabon'},
    {'ccode' : 'GM', 'cname' : 'Gambia'},
    {'ccode' : 'GE', 'cname' : 'Georgia'},
    {'ccode' : 'DE', 'cname' : 'Germany'},
    {'ccode' : 'GH', 'cname' : 'Ghana'},
    {'ccode' : 'GI', 'cname' : 'Gibraltar'},
    {'ccode' : 'GR', 'cname' : 'Greece'},
    {'ccode' : 'GL', 'cname' : 'Greenland'},
    {'ccode' : 'GD', 'cname' : 'Grenada'},
    {'ccode' : 'GP', 'cname' : 'Guadeloupe'},
    {'ccode' : 'GU', 'cname' : 'Guam'},
    {'ccode' : 'GT', 'cname' : 'Guatemala'},
    {'ccode' : 'GG', 'cname' : 'Guernsey'},
    {'ccode' : 'GN', 'cname' : 'Guinea'},
    {'ccode' : 'GW', 'cname' : 'Guinea-Bissau'},
    {'ccode' : 'GY', 'cname' : 'Guyana'},
    {'ccode' : 'HT', 'cname' : 'Haiti'},
    {'ccode' : 'HM', 'cname' : 'Heard Island & Mcdonald Islands'},
    {'ccode' : 'VA', 'cname' : 'Holy See (Vatican City State)'},
    {'ccode' : 'HN', 'cname' : 'Honduras'},
    {'ccode' : 'HK', 'cname' : 'Hong Kong'},
    {'ccode' : 'HU', 'cname' : 'Hungary'},
    {'ccode' : 'IS', 'cname' : 'Iceland'},
    {'ccode' : 'IN', 'cname' : 'India'},
    {'ccode' : 'ID', 'cname' : 'Indonesia'},
    {'ccode' : 'IR', 'cname' : 'Iran, Islamic Republic Of'},
    {'ccode' : 'IQ', 'cname' : 'Iraq'},
    {'ccode' : 'IE', 'cname' : 'Ireland'},
    {'ccode' : 'IM', 'cname' : 'Isle Of Man'},
    {'ccode' : 'IL', 'cname' : 'Israel'},
    {'ccode' : 'IT', 'cname' : 'Italy'},
    {'ccode' : 'JM', 'cname' : 'Jamaica'},
    {'ccode' : 'JP', 'cname' : 'Japan'},
    {'ccode' : 'JE', 'cname' : 'Jersey'},
    {'ccode' : 'JO', 'cname' : 'Jordan'},
    {'ccode' : 'KZ', 'cname' : 'Kazakhstan'},
    {'ccode' : 'KE', 'cname' : 'Kenya'},
    {'ccode' : 'KI', 'cname' : 'Kiribati'},
    {'ccode' : 'KR', 'cname' : 'Korea'},
    {'ccode' : 'KW', 'cname' : 'Kuwait'},
    {'ccode' : 'KG', 'cname' : 'Kyrgyzstan'},
    {'ccode' : 'LA', 'cname' : 'Lao People\'s Democratic Republic'},
    {'ccode' : 'LV', 'cname' : 'Latvia'},
    {'ccode' : 'LB', 'cname' : 'Lebanon'},
    {'ccode' : 'LS', 'cname' : 'Lesotho'},
    {'ccode' : 'LR', 'cname' : 'Liberia'},
    {'ccode' : 'LY', 'cname' : 'Libyan Arab Jamahiriya'},
    {'ccode' : 'LI', 'cname' : 'Liechtenstein'},
    {'ccode' : 'LT', 'cname' : 'Lithuania'},
    {'ccode' : 'LU', 'cname' : 'Luxembourg'},
    {'ccode' : 'MO', 'cname' : 'Macao'},
    {'ccode' : 'MK', 'cname' : 'Macedonia'},
    {'ccode' : 'MG', 'cname' : 'Madagascar'},
    {'ccode' : 'MW', 'cname' : 'Malawi'},
    {'ccode' : 'MY', 'cname' : 'Malaysia'},
    {'ccode' : 'MV', 'cname' : 'Maldives'},
    {'ccode' : 'ML', 'cname' : 'Mali'},
    {'ccode' : 'MT', 'cname' : 'Malta'},
    {'ccode' : 'MH', 'cname' : 'Marshall Islands'},
    {'ccode' : 'MQ', 'cname' : 'Martinique'},
    {'ccode' : 'MR', 'cname' : 'Mauritania'},
    {'ccode' : 'MU', 'cname' : 'Mauritius'},
    {'ccode' : 'YT', 'cname' : 'Mayotte'},
    {'ccode' : 'MX', 'cname' : 'Mexico'},
    {'ccode' : 'FM', 'cname' : 'Micronesia, Federated States Of'},
    {'ccode' : 'MD', 'cname' : 'Moldova'},
    {'ccode' : 'MC', 'cname' : 'Monaco'},
    {'ccode' : 'MN', 'cname' : 'Mongolia'},
    {'ccode' : 'ME', 'cname' : 'Montenegro'},
    {'ccode' : 'MS', 'cname' : 'Montserrat'},
    {'ccode' : 'MA', 'cname' : 'Morocco'},
    {'ccode' : 'MZ', 'cname' : 'Mozambique'},
    {'ccode' : 'MM', 'cname' : 'Myanmar'},
    {'ccode' : 'NA', 'cname' : 'Namibia'},
    {'ccode' : 'NR', 'cname' : 'Nauru'},
    {'ccode' : 'NP', 'cname' : 'Nepal'},
    {'ccode' : 'NL', 'cname' : 'Netherlands'},
    {'ccode' : 'AN', 'cname' : 'Netherlands Antilles'},
    {'ccode' : 'NC', 'cname' : 'New Caledonia'},
    {'ccode' : 'NZ', 'cname' : 'New Zealand'},
    {'ccode' : 'NI', 'cname' : 'Nicaragua'},
    {'ccode' : 'NE', 'cname' : 'Niger'},
    {'ccode' : 'NG', 'cname' : 'Nigeria'},
    {'ccode' : 'NU', 'cname' : 'Niue'},
    {'ccode' : 'NF', 'cname' : 'Norfolk Island'},
    {'ccode' : 'MP', 'cname' : 'Northern Mariana Islands'},
    {'ccode' : 'NO', 'cname' : 'Norway'},
    {'ccode' : 'OM', 'cname' : 'Oman'},
    {'ccode' : 'PK', 'cname' : 'Pakistan'},
    {'ccode' : 'PW', 'cname' : 'Palau'},
    {'ccode' : 'PS', 'cname' : 'Palestinian Territory, Occupied'},
    {'ccode' : 'PA', 'cname' : 'Panama'},
    {'ccode' : 'PG', 'cname' : 'Papua New Guinea'},
    {'ccode' : 'PY', 'cname' : 'Paraguay'},
    {'ccode' : 'PE', 'cname' : 'Peru'},
    {'ccode' : 'PH', 'cname' : 'Philippines'},
    {'ccode' : 'PN', 'cname' : 'Pitcairn'},
    {'ccode' : 'PL', 'cname' : 'Poland'},
    {'ccode' : 'PT', 'cname' : 'Portugal'},
    {'ccode' : 'PR', 'cname' : 'Puerto Rico'},
    {'ccode' : 'QA', 'cname' : 'Qatar'},
    {'ccode' : 'RE', 'cname' : 'Reunion'},
    {'ccode' : 'RO', 'cname' : 'Romania'},
    {'ccode' : 'RU', 'cname' : 'Russian Federation'},
    {'ccode' : 'RW', 'cname' : 'Rwanda'},
    {'ccode' : 'BL', 'cname' : 'Saint Barthelemy'},
    {'ccode' : 'SH', 'cname' : 'Saint Helena'},
    {'ccode' : 'KN', 'cname' : 'Saint Kitts And Nevis'},
    {'ccode' : 'LC', 'cname' : 'Saint Lucia'},
    {'ccode' : 'MF', 'cname' : 'Saint Martin'},
    {'ccode' : 'PM', 'cname' : 'Saint Pierre And Miquelon'},
    {'ccode' : 'VC', 'cname' : 'Saint Vincent And Grenadines'},
    {'ccode' : 'WS', 'cname' : 'Samoa'},
    {'ccode' : 'SM', 'cname' : 'San Marino'},
    {'ccode' : 'ST', 'cname' : 'Sao Tome And Principe'},
    {'ccode' : 'SA', 'cname' : 'Saudi Arabia'},
    {'ccode' : 'SN', 'cname' : 'Senegal'},
    {'ccode' : 'RS', 'cname' : 'Serbia'},
    {'ccode' : 'SC', 'cname' : 'Seychelles'},
    {'ccode' : 'SL', 'cname' : 'Sierra Leone'},
    {'ccode' : 'SG', 'cname' : 'Singapore'},
    {'ccode' : 'SK', 'cname' : 'Slovakia'},
    {'ccode' : 'SI', 'cname' : 'Slovenia'},
    {'ccode' : 'SB', 'cname' : 'Solomon Islands'},
    {'ccode' : 'SO', 'cname' : 'Somalia'},
    {'ccode' : 'ZA', 'cname' : 'South Africa'},
    {'ccode' : 'GS', 'cname' : 'South Georgia And Sandwich Isl.'},
    {'ccode' : 'ES', 'cname' : 'Spain'},
    {'ccode' : 'LK', 'cname' : 'Sri Lanka'},
    {'ccode' : 'SD', 'cname' : 'Sudan'},
    {'ccode' : 'SR', 'cname' : 'Suriname'},
    {'ccode' : 'SJ', 'cname' : 'Svalbard And Jan Mayen'},
    {'ccode' : 'SZ', 'cname' : 'Swaziland'},
    {'ccode' : 'SE', 'cname' : 'Sweden'},
    {'ccode' : 'CH', 'cname' : 'Switzerland'},
    {'ccode' : 'SY', 'cname' : 'Syrian Arab Republic'},
    {'ccode' : 'TW', 'cname' : 'Taiwan'},
    {'ccode' : 'TJ', 'cname' : 'Tajikistan'},
    {'ccode' : 'TZ', 'cname' : 'Tanzania'},
    {'ccode' : 'TH', 'cname' : 'Thailand'},
    {'ccode' : 'TL', 'cname' : 'Timor-Leste'},
    {'ccode' : 'TG', 'cname' : 'Togo'},
    {'ccode' : 'TK', 'cname' : 'Tokelau'},
    {'ccode' : 'TO', 'cname' : 'Tonga'},
    {'ccode' : 'TT', 'cname' : 'Trinidad And Tobago'},
    {'ccode' : 'TN', 'cname' : 'Tunisia'},
    {'ccode' : 'TR', 'cname' : 'Turkey'},
    {'ccode' : 'TM', 'cname' : 'Turkmenistan'},
    {'ccode' : 'TC', 'cname' : 'Turks And Caicos Islands'},
    {'ccode' : 'TV', 'cname' : 'Tuvalu'},
    {'ccode' : 'UG', 'cname' : 'Uganda'},
    {'ccode' : 'UA', 'cname' : 'Ukraine'},
    {'ccode' : 'AE', 'cname' : 'United Arab Emirates'},
    {'ccode' : 'GB', 'cname' : 'United Kingdom'},
    {'ccode' : 'US', 'cname' : 'United States'},
    {'ccode' : 'UM', 'cname' : 'United States Outlying Islands'},
    {'ccode' : 'UY', 'cname' : 'Uruguay'},
    {'ccode' : 'UZ', 'cname' : 'Uzbekistan'},
    {'ccode' : 'VU', 'cname' : 'Vanuatu'},
    {'ccode' : 'VE', 'cname' : 'Venezuela'},
    {'ccode' : 'VN', 'cname' : 'Viet Nam'},
    {'ccode' : 'VG', 'cname' : 'Virgin Islands, British'},
    {'ccode' : 'VI', 'cname' : 'Virgin Islands, U.S.'},
    {'ccode' : 'WF', 'cname' : 'Wallis And Futuna'},
    {'ccode' : 'EH', 'cname' : 'Western Sahara'},
    {'ccode' : 'YE', 'cname' : 'Yemen'},
    {'ccode' : 'ZM', 'cname' : 'Zambia'},
    {'ccode' : 'ZW', 'cname' : 'Zimbabwe'}
];

function CountryModel() {
    var self = this;
    self.availableCountries = ko.observableArray(isoCountries);
}

ko.applyBindings(new CountryModel());
@xecgr

This comment has been minimized.

Show comment
Hide comment
@xecgr

xecgr Oct 18, 2015

I've used your script since the begining of my project and now I had to translated to several languages.
So, I've attached my scripts in order to improve and complete your work.
Thanks!
https://gist.github.com/xecgr/c753d36735c6e629c4d1
https://gist.github.com/xecgr/a1e864b8d1ad1884cd7a
https://gist.github.com/xecgr/dbf00d3ffa4a0ec7d2e7

xecgr commented Oct 18, 2015

I've used your script since the begining of my project and now I had to translated to several languages.
So, I've attached my scripts in order to improve and complete your work.
Thanks!
https://gist.github.com/xecgr/c753d36735c6e629c4d1
https://gist.github.com/xecgr/a1e864b8d1ad1884cd7a
https://gist.github.com/xecgr/dbf00d3ffa4a0ec7d2e7

@tomffee

This comment has been minimized.

Show comment
Hide comment
@tomffee

tomffee Nov 10, 2015

Wouldn't be better do it this way?

const isoCountries = {
  'AF' : {
    name: 'Afghanistan',
  },
  'AX' : {
    name: 'Aland Islands',
  },
  'AL' : {
    name: 'Albania',
  },
  'DZ' : {
    name: 'Algeria',
  },
  'AS' : {
    name: 'American Samoa',
  },
  'AD' : {
    name: 'Andorra',
  },
  'AO' : {
    name: 'Angola',
  },
  'AI' : {
    name: 'Anguilla',
  },
  'AQ' : {
    name: 'Antarctica',
  },
  'AG' : {
    name: 'Antigua And Barbuda',
  },
  'AR' : {
    name: 'Argentina',
  },
  'AM' : {
    name: 'Armenia',
  },
  'AW' : {
    name: 'Aruba',
  },
  'AU' : {
    name: 'Australia',
  },
  'AT' : {
    name: 'Austria',
  },
  'AZ' : {
    name: 'Azerbaijan',
  },
  'BS' : {
    name: 'Bahamas',
  },
  'BH' : {
    name: 'Bahrain',
  },
  'BD' : {
    name: 'Bangladesh',
  },
  'BB' : {
    name: 'Barbados',
  },
  'BY' : {
    name: 'Belarus',
  },
  'BE' : {
    name: 'Belgium',
  },
  'BZ' : {
    name: 'Belize',
  },
  'BJ' : {
    name: 'Benin',
  },
  'BM' : {
    name: 'Bermuda',
  },
  'BT' : {
    name: 'Bhutan',
  },
  'BO' : {
    name: 'Bolivia',
  },
  'BA' : {
    name: 'Bosnia And Herzegovina',
  },
  'BW' : {
    name: 'Botswana',
  },
  'BV' : {
    name: 'Bouvet Island',
  },
  'BR' : {
    name: 'Brazil',
  },
  'IO' : {
    name: 'British Indian Ocean Territory',
  },
  'BN' : {
    name: 'Brunei Darussalam',
  },
  'BG' : {
    name: 'Bulgaria',
  },
  'BF' : {
    name: 'Burkina Faso',
  },
  'BI' : {
    name: 'Burundi',
  },
  'KH' : {
    name: 'Cambodia',
  },
  'CM' : {
    name: 'Cameroon',
  },
  'CA' : {
    name: 'Canada',
  },
  'CV' : {
    name: 'Cape Verde',
  },
  'KY' : {
    name: 'Cayman Islands',
  },
  'CF' : {
    name: 'Central African Republic',
  },
  'TD' : {
    name: 'Chad',
  },
  'CL' : {
    name: 'Chile',
  },
  'CN' : {
    name: 'China',
  },
  'CX' : {
    name: 'Christmas Island',
  },
  'CC' : {
    name: 'Cocos (Keeling) Islands',
  },
  'CO' : {
    name: 'Colombia',
  },
  'KM' : {
    name: 'Comoros',
  },
  'CG' : {
    name: 'Congo',
  },
  'CD' : {
    name: 'Congo, Democratic Republic',
  },
  'CK' : {
    name: 'Cook Islands',
  },
  'CR' : {
    name: 'Costa Rica',
  },
  'CI' : {
    name: 'Cote D\'Ivoire',
  },
  'HR' : {
    name: 'Croatia',
  },
  'CU' : {
    name: 'Cuba',
  },
  'CY' : {
    name: 'Cyprus',
  },
  'CZ' : {
    name: 'Czech Republic',
  },
  'DK' : {
    name: 'Denmark',
  },
  'DJ' : {
    name: 'Djibouti',
  },
  'DM' : {
    name: 'Dominica',
  },
  'DO' : {
    name: 'Dominican Republic',
  },
  'EC' : {
    name: 'Ecuador',
  },
  'EG' : {
    name: 'Egypt',
  },
  'SV' : {
    name: 'El Salvador',
  },
  'GQ' : {
    name: 'Equatorial Guinea',
  },
  'ER' : {
    name: 'Eritrea',
  },
  'EE' : {
    name: 'Estonia',
  },
  'ET' : {
    name: 'Ethiopia',
  },
  'FK' : {
    name: 'Falkland Islands (Malvinas)',
  },
  'FO' : {
    name: 'Faroe Islands',
  },
  'FJ' : {
    name: 'Fiji',
  },
  'FI' : {
    name: 'Finland',
  },
  'FR' : {
    name: 'France',
  },
  'GF' : {
    name: 'French Guiana',
  },
  'PF' : {
    name: 'French Polynesia',
  },
  'TF' : {
    name: 'French Southern Territories',
  },
  'GA' : {
    name: 'Gabon',
  },
  'GM' : {
    name: 'Gambia',
  },
  'GE' : {
    name: 'Georgia',
  },
  'DE' : {
    name: 'Germany',
  },
  'GH' : {
    name: 'Ghana',
  },
  'GI' : {
    name: 'Gibraltar',
  },
  'GR' : {
    name: 'Greece',
  },
  'GL' : {
    name: 'Greenland',
  },
  'GD' : {
    name: 'Grenada',
  },
  'GP' : {
    name: 'Guadeloupe',
  },
  'GU' : {
    name: 'Guam',
  },
  'GT' : {
    name: 'Guatemala',
  },
  'GG' : {
    name: 'Guernsey',
  },
  'GN' : {
    name: 'Guinea',
  },
  'GW' : {
    name: 'Guinea-Bissau',
  },
  'GY' : {
    name: 'Guyana',
  },
  'HT' : {
    name: 'Haiti',
  },
  'HM' : {
    name: 'Heard Island & Mcdonald Islands',
  },
  'VA' : {
    name: 'Holy See (Vatican City State)',
  },
  'HN' : {
    name: 'Honduras',
  },
  'HK' : {
    name: 'Hong Kong',
  },
  'HU' : {
    name: 'Hungary',
  },
  'IS' : {
    name: 'Iceland',
  },
  'IN' : {
    name: 'India',
  },
  'ID' : {
    name: 'Indonesia',
  },
  'IR' : {
    name: 'Iran, Islamic Republic Of',
  },
  'IQ' : {
    name: 'Iraq',
  },
  'IE' : {
    name: 'Ireland',
  },
  'IM' : {
    name: 'Isle Of Man',
  },
  'IL' : {
    name: 'Israel',
  },
  'IT' : {
    name: 'Italy',
  },
  'JM' : {
    name: 'Jamaica',
  },
  'JP' : {
    name: 'Japan',
  },
  'JE' : {
    name: 'Jersey',
  },
  'JO' : {
    name: 'Jordan',
  },
  'KZ' : {
    name: 'Kazakhstan',
  },
  'KE' : {
    name: 'Kenya',
  },
  'KI' : {
    name: 'Kiribati',
  },
  'KR' : {
    name: 'Korea',
  },
  'KW' : {
    name: 'Kuwait',
  },
  'KG' : {
    name: 'Kyrgyzstan',
  },
  'LA' : {
    name: 'Lao People\'s Democratic Republic',
  },
  'LV' : {
    name: 'Latvia',
  },
  'LB' : {
    name: 'Lebanon',
  },
  'LS' : {
    name: 'Lesotho',
  },
  'LR' : {
    name: 'Liberia',
  },
  'LY' : {
    name: 'Libyan Arab Jamahiriya',
  },
  'LI' : {
    name: 'Liechtenstein',
  },
  'LT' : {
    name: 'Lithuania',
  },
  'LU' : {
    name: 'Luxembourg',
  },
  'MO' : {
    name: 'Macao',
  },
  'MK' : {
    name: 'Macedonia',
  },
  'MG' : {
    name: 'Madagascar',
  },
  'MW' : {
    name: 'Malawi',
  },
  'MY' : {
    name: 'Malaysia',
  },
  'MV' : {
    name: 'Maldives',
  },
  'ML' : {
    name: 'Mali',
  },
  'MT' : {
    name: 'Malta',
  },
  'MH' : {
    name: 'Marshall Islands',
  },
  'MQ' : {
    name: 'Martinique',
  },
  'MR' : {
    name: 'Mauritania',
  },
  'MU' : {
    name: 'Mauritius',
  },
  'YT' : {
    name: 'Mayotte',
  },
  'MX' : {
    name: 'Mexico',
  },
  'FM' : {
    name: 'Micronesia, Federated States Of',
  },
  'MD' : {
    name: 'Moldova',
  },
  'MC' : {
    name: 'Monaco',
  },
  'MN' : {
    name: 'Mongolia',
  },
  'ME' : {
    name: 'Montenegro',
  },
  'MS' : {
    name: 'Montserrat',
  },
  'MA' : {
    name: 'Morocco',
  },
  'MZ' : {
    name: 'Mozambique',
  },
  'MM' : {
    name: 'Myanmar',
  },
  'NA' : {
    name: 'Namibia',
  },
  'NR' : {
    name: 'Nauru',
  },
  'NP' : {
    name: 'Nepal',
  },
  'NL' : {
    name: 'Netherlands',
  },
  'AN' : {
    name: 'Netherlands Antilles',
  },
  'NC' : {
    name: 'New Caledonia',
  },
  'NZ' : {
    name: 'New Zealand',
  },
  'NI' : {
    name: 'Nicaragua',
  },
  'NE' : {
    name: 'Niger',
  },
  'NG' : {
    name: 'Nigeria',
  },
  'NU' : {
    name: 'Niue',
  },
  'NF' : {
    name: 'Norfolk Island',
  },
  'MP' : {
    name: 'Northern Mariana Islands',
  },
  'NO' : {
    name: 'Norway',
  },
  'OM' : {
    name: 'Oman',
  },
  'PK' : {
    name: 'Pakistan',
  },
  'PW' : {
    name: 'Palau',
  },
  'PS' : {
    name: 'Palestinian Territory, Occupied',
  },
  'PA' : {
    name: 'Panama',
  },
  'PG' : {
    name: 'Papua New Guinea',
  },
  'PY' : {
    name: 'Paraguay',
  },
  'PE' : {
    name: 'Peru',
  },
  'PH' : {
    name: 'Philippines',
  },
  'PN' : {
    name: 'Pitcairn',
  },
  'PL' : {
    name: 'Poland',
  },
  'PT' : {
    name: 'Portugal',
  },
  'PR' : {
    name: 'Puerto Rico',
  },
  'QA' : {
    name: 'Qatar',
  },
  'RE' : {
    name: 'Reunion',
  },
  'RO' : {
    name: 'Romania',
  },
  'RU' : {
    name: 'Russian Federation',
  },
  'RW' : {
    name: 'Rwanda',
  },
  'BL' : {
    name: 'Saint Barthelemy',
  },
  'SH' : {
    name: 'Saint Helena',
  },
  'KN' : {
    name: 'Saint Kitts And Nevis',
  },
  'LC' : {
    name: 'Saint Lucia',
  },
  'MF' : {
    name: 'Saint Martin',
  },
  'PM' : {
    name: 'Saint Pierre And Miquelon',
  },
  'VC' : {
    name: 'Saint Vincent And Grenadines',
  },
  'WS' : {
    name: 'Samoa',
  },
  'SM' : {
    name: 'San Marino',
  },
  'ST' : {
    name: 'Sao Tome And Principe',
  },
  'SA' : {
    name: 'Saudi Arabia',
  },
  'SN' : {
    name: 'Senegal',
  },
  'RS' : {
    name: 'Serbia',
  },
  'SC' : {
    name: 'Seychelles',
  },
  'SL' : {
    name: 'Sierra Leone',
  },
  'SG' : {
    name: 'Singapore',
  },
  'SK' : {
    name: 'Slovakia',
  },
  'SI' : {
    name: 'Slovenia',
  },
  'SB' : {
    name: 'Solomon Islands',
  },
  'SO' : {
    name: 'Somalia',
  },
  'ZA' : {
    name: 'South Africa',
  },
  'GS' : {
    name: 'South Georgia And Sandwich Isl.',
  },
  'ES' : {
    name: 'Spain',
  },
  'LK' : {
    name: 'Sri Lanka',
  },
  'SD' : {
    name: 'Sudan',
  },
  'SR' : {
    name: 'Suriname',
  },
  'SJ' : {
    name: 'Svalbard And Jan Mayen',
  },
  'SZ' : {
    name: 'Swaziland',
  },
  'SE' : {
    name: 'Sweden',
  },
  'CH' : {
    name: 'Switzerland',
  },
  'SY' : {
    name: 'Syrian Arab Republic',
  },
  'TW' : {
    name: 'Taiwan',
  },
  'TJ' : {
    name: 'Tajikistan',
  },
  'TZ' : {
    name: 'Tanzania',
  },
  'TH' : {
    name: 'Thailand',
  },
  'TL' : {
    name: 'Timor-Leste',
  },
  'TG' : {
    name: 'Togo',
  },
  'TK' : {
    name: 'Tokelau',
  },
  'TO' : {
    name: 'Tonga',
  },
  'TT' : {
    name: 'Trinidad And Tobago',
  },
  'TN' : {
    name: 'Tunisia',
  },
  'TR' : {
    name: 'Turkey',
  },
  'TM' : {
    name: 'Turkmenistan',
  },
  'TC' : {
    name: 'Turks And Caicos Islands',
  },
  'TV' : {
    name: 'Tuvalu',
  },
  'UG' : {
    name: 'Uganda',
  },
  'UA' : {
    name: 'Ukraine',
  },
  'AE' : {
    name: 'United Arab Emirates',
  },
  'GB' : {
    name: 'United Kingdom',
  },
  'US' : {
    name: 'United States',
  },
  'UM' : {
    name: 'United States Outlying Islands',
  },
  'UY' : {
    name: 'Uruguay',
  },
  'UZ' : {
    name: 'Uzbekistan',
  },
  'VU' : {
    name: 'Vanuatu',
  },
  'VE' : {
    name: 'Venezuela',
  },
  'VN' : {
    name: 'Viet Nam',
  },
  'VG' : {
    name: 'Virgin Islands, British',
  },
  'VI' : {
    name: 'Virgin Islands, U.S.',
  },
  'WF' : {
    name: 'Wallis And Futuna',
  },
  'EH' : {
    name: 'Western Sahara',
  },
  'YE' : {
    name: 'Yemen',
  },
  'ZM' : {
    name: 'Zambia',
  },
  'ZW' : {
    name: 'Zimbabwe'
  },
};

So now you can simply do this:

convertCountryCode = (code) => {
    return isoCountries[code].name;
}```

tomffee commented Nov 10, 2015

Wouldn't be better do it this way?

const isoCountries = {
  'AF' : {
    name: 'Afghanistan',
  },
  'AX' : {
    name: 'Aland Islands',
  },
  'AL' : {
    name: 'Albania',
  },
  'DZ' : {
    name: 'Algeria',
  },
  'AS' : {
    name: 'American Samoa',
  },
  'AD' : {
    name: 'Andorra',
  },
  'AO' : {
    name: 'Angola',
  },
  'AI' : {
    name: 'Anguilla',
  },
  'AQ' : {
    name: 'Antarctica',
  },
  'AG' : {
    name: 'Antigua And Barbuda',
  },
  'AR' : {
    name: 'Argentina',
  },
  'AM' : {
    name: 'Armenia',
  },
  'AW' : {
    name: 'Aruba',
  },
  'AU' : {
    name: 'Australia',
  },
  'AT' : {
    name: 'Austria',
  },
  'AZ' : {
    name: 'Azerbaijan',
  },
  'BS' : {
    name: 'Bahamas',
  },
  'BH' : {
    name: 'Bahrain',
  },
  'BD' : {
    name: 'Bangladesh',
  },
  'BB' : {
    name: 'Barbados',
  },
  'BY' : {
    name: 'Belarus',
  },
  'BE' : {
    name: 'Belgium',
  },
  'BZ' : {
    name: 'Belize',
  },
  'BJ' : {
    name: 'Benin',
  },
  'BM' : {
    name: 'Bermuda',
  },
  'BT' : {
    name: 'Bhutan',
  },
  'BO' : {
    name: 'Bolivia',
  },
  'BA' : {
    name: 'Bosnia And Herzegovina',
  },
  'BW' : {
    name: 'Botswana',
  },
  'BV' : {
    name: 'Bouvet Island',
  },
  'BR' : {
    name: 'Brazil',
  },
  'IO' : {
    name: 'British Indian Ocean Territory',
  },
  'BN' : {
    name: 'Brunei Darussalam',
  },
  'BG' : {
    name: 'Bulgaria',
  },
  'BF' : {
    name: 'Burkina Faso',
  },
  'BI' : {
    name: 'Burundi',
  },
  'KH' : {
    name: 'Cambodia',
  },
  'CM' : {
    name: 'Cameroon',
  },
  'CA' : {
    name: 'Canada',
  },
  'CV' : {
    name: 'Cape Verde',
  },
  'KY' : {
    name: 'Cayman Islands',
  },
  'CF' : {
    name: 'Central African Republic',
  },
  'TD' : {
    name: 'Chad',
  },
  'CL' : {
    name: 'Chile',
  },
  'CN' : {
    name: 'China',
  },
  'CX' : {
    name: 'Christmas Island',
  },
  'CC' : {
    name: 'Cocos (Keeling) Islands',
  },
  'CO' : {
    name: 'Colombia',
  },
  'KM' : {
    name: 'Comoros',
  },
  'CG' : {
    name: 'Congo',
  },
  'CD' : {
    name: 'Congo, Democratic Republic',
  },
  'CK' : {
    name: 'Cook Islands',
  },
  'CR' : {
    name: 'Costa Rica',
  },
  'CI' : {
    name: 'Cote D\'Ivoire',
  },
  'HR' : {
    name: 'Croatia',
  },
  'CU' : {
    name: 'Cuba',
  },
  'CY' : {
    name: 'Cyprus',
  },
  'CZ' : {
    name: 'Czech Republic',
  },
  'DK' : {
    name: 'Denmark',
  },
  'DJ' : {
    name: 'Djibouti',
  },
  'DM' : {
    name: 'Dominica',
  },
  'DO' : {
    name: 'Dominican Republic',
  },
  'EC' : {
    name: 'Ecuador',
  },
  'EG' : {
    name: 'Egypt',
  },
  'SV' : {
    name: 'El Salvador',
  },
  'GQ' : {
    name: 'Equatorial Guinea',
  },
  'ER' : {
    name: 'Eritrea',
  },
  'EE' : {
    name: 'Estonia',
  },
  'ET' : {
    name: 'Ethiopia',
  },
  'FK' : {
    name: 'Falkland Islands (Malvinas)',
  },
  'FO' : {
    name: 'Faroe Islands',
  },
  'FJ' : {
    name: 'Fiji',
  },
  'FI' : {
    name: 'Finland',
  },
  'FR' : {
    name: 'France',
  },
  'GF' : {
    name: 'French Guiana',
  },
  'PF' : {
    name: 'French Polynesia',
  },
  'TF' : {
    name: 'French Southern Territories',
  },
  'GA' : {
    name: 'Gabon',
  },
  'GM' : {
    name: 'Gambia',
  },
  'GE' : {
    name: 'Georgia',
  },
  'DE' : {
    name: 'Germany',
  },
  'GH' : {
    name: 'Ghana',
  },
  'GI' : {
    name: 'Gibraltar',
  },
  'GR' : {
    name: 'Greece',
  },
  'GL' : {
    name: 'Greenland',
  },
  'GD' : {
    name: 'Grenada',
  },
  'GP' : {
    name: 'Guadeloupe',
  },
  'GU' : {
    name: 'Guam',
  },
  'GT' : {
    name: 'Guatemala',
  },
  'GG' : {
    name: 'Guernsey',
  },
  'GN' : {
    name: 'Guinea',
  },
  'GW' : {
    name: 'Guinea-Bissau',
  },
  'GY' : {
    name: 'Guyana',
  },
  'HT' : {
    name: 'Haiti',
  },
  'HM' : {
    name: 'Heard Island & Mcdonald Islands',
  },
  'VA' : {
    name: 'Holy See (Vatican City State)',
  },
  'HN' : {
    name: 'Honduras',
  },
  'HK' : {
    name: 'Hong Kong',
  },
  'HU' : {
    name: 'Hungary',
  },
  'IS' : {
    name: 'Iceland',
  },
  'IN' : {
    name: 'India',
  },
  'ID' : {
    name: 'Indonesia',
  },
  'IR' : {
    name: 'Iran, Islamic Republic Of',
  },
  'IQ' : {
    name: 'Iraq',
  },
  'IE' : {
    name: 'Ireland',
  },
  'IM' : {
    name: 'Isle Of Man',
  },
  'IL' : {
    name: 'Israel',
  },
  'IT' : {
    name: 'Italy',
  },
  'JM' : {
    name: 'Jamaica',
  },
  'JP' : {
    name: 'Japan',
  },
  'JE' : {
    name: 'Jersey',
  },
  'JO' : {
    name: 'Jordan',
  },
  'KZ' : {
    name: 'Kazakhstan',
  },
  'KE' : {
    name: 'Kenya',
  },
  'KI' : {
    name: 'Kiribati',
  },
  'KR' : {
    name: 'Korea',
  },
  'KW' : {
    name: 'Kuwait',
  },
  'KG' : {
    name: 'Kyrgyzstan',
  },
  'LA' : {
    name: 'Lao People\'s Democratic Republic',
  },
  'LV' : {
    name: 'Latvia',
  },
  'LB' : {
    name: 'Lebanon',
  },
  'LS' : {
    name: 'Lesotho',
  },
  'LR' : {
    name: 'Liberia',
  },
  'LY' : {
    name: 'Libyan Arab Jamahiriya',
  },
  'LI' : {
    name: 'Liechtenstein',
  },
  'LT' : {
    name: 'Lithuania',
  },
  'LU' : {
    name: 'Luxembourg',
  },
  'MO' : {
    name: 'Macao',
  },
  'MK' : {
    name: 'Macedonia',
  },
  'MG' : {
    name: 'Madagascar',
  },
  'MW' : {
    name: 'Malawi',
  },
  'MY' : {
    name: 'Malaysia',
  },
  'MV' : {
    name: 'Maldives',
  },
  'ML' : {
    name: 'Mali',
  },
  'MT' : {
    name: 'Malta',
  },
  'MH' : {
    name: 'Marshall Islands',
  },
  'MQ' : {
    name: 'Martinique',
  },
  'MR' : {
    name: 'Mauritania',
  },
  'MU' : {
    name: 'Mauritius',
  },
  'YT' : {
    name: 'Mayotte',
  },
  'MX' : {
    name: 'Mexico',
  },
  'FM' : {
    name: 'Micronesia, Federated States Of',
  },
  'MD' : {
    name: 'Moldova',
  },
  'MC' : {
    name: 'Monaco',
  },
  'MN' : {
    name: 'Mongolia',
  },
  'ME' : {
    name: 'Montenegro',
  },
  'MS' : {
    name: 'Montserrat',
  },
  'MA' : {
    name: 'Morocco',
  },
  'MZ' : {
    name: 'Mozambique',
  },
  'MM' : {
    name: 'Myanmar',
  },
  'NA' : {
    name: 'Namibia',
  },
  'NR' : {
    name: 'Nauru',
  },
  'NP' : {
    name: 'Nepal',
  },
  'NL' : {
    name: 'Netherlands',
  },
  'AN' : {
    name: 'Netherlands Antilles',
  },
  'NC' : {
    name: 'New Caledonia',
  },
  'NZ' : {
    name: 'New Zealand',
  },
  'NI' : {
    name: 'Nicaragua',
  },
  'NE' : {
    name: 'Niger',
  },
  'NG' : {
    name: 'Nigeria',
  },
  'NU' : {
    name: 'Niue',
  },
  'NF' : {
    name: 'Norfolk Island',
  },
  'MP' : {
    name: 'Northern Mariana Islands',
  },
  'NO' : {
    name: 'Norway',
  },
  'OM' : {
    name: 'Oman',
  },
  'PK' : {
    name: 'Pakistan',
  },
  'PW' : {
    name: 'Palau',
  },
  'PS' : {
    name: 'Palestinian Territory, Occupied',
  },
  'PA' : {
    name: 'Panama',
  },
  'PG' : {
    name: 'Papua New Guinea',
  },
  'PY' : {
    name: 'Paraguay',
  },
  'PE' : {
    name: 'Peru',
  },
  'PH' : {
    name: 'Philippines',
  },
  'PN' : {
    name: 'Pitcairn',
  },
  'PL' : {
    name: 'Poland',
  },
  'PT' : {
    name: 'Portugal',
  },
  'PR' : {
    name: 'Puerto Rico',
  },
  'QA' : {
    name: 'Qatar',
  },
  'RE' : {
    name: 'Reunion',
  },
  'RO' : {
    name: 'Romania',
  },
  'RU' : {
    name: 'Russian Federation',
  },
  'RW' : {
    name: 'Rwanda',
  },
  'BL' : {
    name: 'Saint Barthelemy',
  },
  'SH' : {
    name: 'Saint Helena',
  },
  'KN' : {
    name: 'Saint Kitts And Nevis',
  },
  'LC' : {
    name: 'Saint Lucia',
  },
  'MF' : {
    name: 'Saint Martin',
  },
  'PM' : {
    name: 'Saint Pierre And Miquelon',
  },
  'VC' : {
    name: 'Saint Vincent And Grenadines',
  },
  'WS' : {
    name: 'Samoa',
  },
  'SM' : {
    name: 'San Marino',
  },
  'ST' : {
    name: 'Sao Tome And Principe',
  },
  'SA' : {
    name: 'Saudi Arabia',
  },
  'SN' : {
    name: 'Senegal',
  },
  'RS' : {
    name: 'Serbia',
  },
  'SC' : {
    name: 'Seychelles',
  },
  'SL' : {
    name: 'Sierra Leone',
  },
  'SG' : {
    name: 'Singapore',
  },
  'SK' : {
    name: 'Slovakia',
  },
  'SI' : {
    name: 'Slovenia',
  },
  'SB' : {
    name: 'Solomon Islands',
  },
  'SO' : {
    name: 'Somalia',
  },
  'ZA' : {
    name: 'South Africa',
  },
  'GS' : {
    name: 'South Georgia And Sandwich Isl.',
  },
  'ES' : {
    name: 'Spain',
  },
  'LK' : {
    name: 'Sri Lanka',
  },
  'SD' : {
    name: 'Sudan',
  },
  'SR' : {
    name: 'Suriname',
  },
  'SJ' : {
    name: 'Svalbard And Jan Mayen',
  },
  'SZ' : {
    name: 'Swaziland',
  },
  'SE' : {
    name: 'Sweden',
  },
  'CH' : {
    name: 'Switzerland',
  },
  'SY' : {
    name: 'Syrian Arab Republic',
  },
  'TW' : {
    name: 'Taiwan',
  },
  'TJ' : {
    name: 'Tajikistan',
  },
  'TZ' : {
    name: 'Tanzania',
  },
  'TH' : {
    name: 'Thailand',
  },
  'TL' : {
    name: 'Timor-Leste',
  },
  'TG' : {
    name: 'Togo',
  },
  'TK' : {
    name: 'Tokelau',
  },
  'TO' : {
    name: 'Tonga',
  },
  'TT' : {
    name: 'Trinidad And Tobago',
  },
  'TN' : {
    name: 'Tunisia',
  },
  'TR' : {
    name: 'Turkey',
  },
  'TM' : {
    name: 'Turkmenistan',
  },
  'TC' : {
    name: 'Turks And Caicos Islands',
  },
  'TV' : {
    name: 'Tuvalu',
  },
  'UG' : {
    name: 'Uganda',
  },
  'UA' : {
    name: 'Ukraine',
  },
  'AE' : {
    name: 'United Arab Emirates',
  },
  'GB' : {
    name: 'United Kingdom',
  },
  'US' : {
    name: 'United States',
  },
  'UM' : {
    name: 'United States Outlying Islands',
  },
  'UY' : {
    name: 'Uruguay',
  },
  'UZ' : {
    name: 'Uzbekistan',
  },
  'VU' : {
    name: 'Vanuatu',
  },
  'VE' : {
    name: 'Venezuela',
  },
  'VN' : {
    name: 'Viet Nam',
  },
  'VG' : {
    name: 'Virgin Islands, British',
  },
  'VI' : {
    name: 'Virgin Islands, U.S.',
  },
  'WF' : {
    name: 'Wallis And Futuna',
  },
  'EH' : {
    name: 'Western Sahara',
  },
  'YE' : {
    name: 'Yemen',
  },
  'ZM' : {
    name: 'Zambia',
  },
  'ZW' : {
    name: 'Zimbabwe'
  },
};

So now you can simply do this:

convertCountryCode = (code) => {
    return isoCountries[code].name;
}```
@acefxlabs

This comment has been minimized.

Show comment
Hide comment
@acefxlabs

acefxlabs Dec 9, 2015

All Thanks

acefxlabs commented Dec 9, 2015

All Thanks

@adelavegaf

This comment has been minimized.

Show comment
Hide comment
@adelavegaf

adelavegaf commented Apr 21, 2016

Thanks

@ericdouglas

This comment has been minimized.

Show comment
Hide comment
@ericdouglas

ericdouglas commented Jul 7, 2016

Thanks!

@philsam

This comment has been minimized.

Show comment
Hide comment
@philsam

philsam Aug 7, 2016

For Angular JS users: Use it as a Service

$scope.CountryName = "Nigeria";

CountryIso($scope.CountryName)

// Returns the ISO Country Code for the
// given CountryName
angular.module('YourApp').factory('CountryIso', function() {
var isoCountries1 = [
{'ccode' : 'AF', 'cname' : 'Afghanistan'},
{'ccode' : 'AX', 'cname' : 'Aland Islands'},
{'ccode' : 'AL', 'cname' : 'Albania'},
{'ccode' : 'DZ', 'cname' : 'Algeria'},
{'ccode' : 'AS', 'cname' : 'American Samoa'},
{'ccode' : 'AD', 'cname' : 'Andorra'},
{'ccode' : 'AO', 'cname' : 'Angola'},
{'ccode' : 'AI', 'cname' : 'Anguilla'},
{'ccode' : 'AQ', 'cname' : 'Antarctica'},
{'ccode' : 'AG', 'cname' : 'Antigua And Barbuda'},
{'ccode' : 'AR', 'cname' : 'Argentina'},
{'ccode' : 'AM', 'cname' : 'Armenia'},
{'ccode' : 'AW', 'cname' : 'Aruba'},
{'ccode' : 'AU', 'cname' : 'Australia'},
{'ccode' : 'AT', 'cname' : 'Austria'},
{'ccode' : 'AZ', 'cname' : 'Azerbaijan'},
{'ccode' : 'BS', 'cname' : 'Bahamas'},
{'ccode' : 'BH', 'cname' : 'Bahrain'},
{'ccode' : 'BD', 'cname' : 'Bangladesh'},
{'ccode' : 'BB', 'cname' : 'Barbados'},
{'ccode' : 'BY', 'cname' : 'Belarus'},
{'ccode' : 'BE', 'cname' : 'Belgium'},
{'ccode' : 'BZ', 'cname' : 'Belize'},
{'ccode' : 'BJ', 'cname' : 'Benin'},
{'ccode' : 'BM', 'cname' : 'Bermuda'},
{'ccode' : 'BT', 'cname' : 'Bhutan'},
{'ccode' : 'BO', 'cname' : 'Bolivia'},
{'ccode' : 'BA', 'cname' : 'Bosnia And Herzegovina'},
{'ccode' : 'BW', 'cname' : 'Botswana'},
{'ccode' : 'BV', 'cname' : 'Bouvet Island'},
{'ccode' : 'BR', 'cname' : 'Brazil'},
{'ccode' : 'IO', 'cname' : 'British Indian Ocean Territory'},
{'ccode' : 'BN', 'cname' : 'Brunei Darussalam'},
{'ccode' : 'BG', 'cname' : 'Bulgaria'},
{'ccode' : 'BF', 'cname' : 'Burkina Faso'},
{'ccode' : 'BI', 'cname' : 'Burundi'},
{'ccode' : 'KH', 'cname' : 'Cambodia'},
{'ccode' : 'CM', 'cname' : 'Cameroon'},
{'ccode' : 'CA', 'cname' : 'Canada'},
{'ccode' : 'CV', 'cname' : 'Cape Verde'},
{'ccode' : 'KY', 'cname' : 'Cayman Islands'},
{'ccode' : 'CF', 'cname' : 'Central African Republic'},
{'ccode' : 'TD', 'cname' : 'Chad'},
{'ccode' : 'CL', 'cname' : 'Chile'},
{'ccode' : 'CN', 'cname' : 'China'},
{'ccode' : 'CX', 'cname' : 'Christmas Island'},
{'ccode' : 'CC', 'cname' : 'Cocos (Keeling) Islands'},
{'ccode' : 'CO', 'cname' : 'Colombia'},
{'ccode' : 'KM', 'cname' : 'Comoros'},
{'ccode' : 'CG', 'cname' : 'Congo'},
{'ccode' : 'CD', 'cname' : 'Congo, Democratic Republic'},
{'ccode' : 'CK', 'cname' : 'Cook Islands'},
{'ccode' : 'CR', 'cname' : 'Costa Rica'},
{'ccode' : 'CI', 'cname' : 'Cote D'Ivoire'},
{'ccode' : 'HR', 'cname' : 'Croatia'},
{'ccode' : 'CU', 'cname' : 'Cuba'},
{'ccode' : 'CY', 'cname' : 'Cyprus'},
{'ccode' : 'CZ', 'cname' : 'Czech Republic'},
{'ccode' : 'DK', 'cname' : 'Denmark'},
{'ccode' : 'DJ', 'cname' : 'Djibouti'},
{'ccode' : 'DM', 'cname' : 'Dominica'},
{'ccode' : 'DO', 'cname' : 'Dominican Republic'},
{'ccode' : 'EC', 'cname' : 'Ecuador'},
{'ccode' : 'EG', 'cname' : 'Egypt'},
{'ccode' : 'SV', 'cname' : 'El Salvador'},
{'ccode' : 'GQ', 'cname' : 'Equatorial Guinea'},
{'ccode' : 'ER', 'cname' : 'Eritrea'},
{'ccode' : 'EE', 'cname' : 'Estonia'},
{'ccode' : 'ET', 'cname' : 'Ethiopia'},
{'ccode' : 'FK', 'cname' : 'Falkland Islands (Malvinas)'},
{'ccode' : 'FO', 'cname' : 'Faroe Islands'},
{'ccode' : 'FJ', 'cname' : 'Fiji'},
{'ccode' : 'FI', 'cname' : 'Finland'},
{'ccode' : 'FR', 'cname' : 'France'},
{'ccode' : 'GF', 'cname' : 'French Guiana'},
{'ccode' : 'PF', 'cname' : 'French Polynesia'},
{'ccode' : 'TF', 'cname' : 'French Southern Territories'},
{'ccode' : 'GA', 'cname' : 'Gabon'},
{'ccode' : 'GM', 'cname' : 'Gambia'},
{'ccode' : 'GE', 'cname' : 'Georgia'},
{'ccode' : 'DE', 'cname' : 'Germany'},
{'ccode' : 'GH', 'cname' : 'Ghana'},
{'ccode' : 'GI', 'cname' : 'Gibraltar'},
{'ccode' : 'GR', 'cname' : 'Greece'},
{'ccode' : 'GL', 'cname' : 'Greenland'},
{'ccode' : 'GD', 'cname' : 'Grenada'},
{'ccode' : 'GP', 'cname' : 'Guadeloupe'},
{'ccode' : 'GU', 'cname' : 'Guam'},
{'ccode' : 'GT', 'cname' : 'Guatemala'},
{'ccode' : 'GG', 'cname' : 'Guernsey'},
{'ccode' : 'GN', 'cname' : 'Guinea'},
{'ccode' : 'GW', 'cname' : 'Guinea-Bissau'},
{'ccode' : 'GY', 'cname' : 'Guyana'},
{'ccode' : 'HT', 'cname' : 'Haiti'},
{'ccode' : 'HM', 'cname' : 'Heard Island & Mcdonald Islands'},
{'ccode' : 'VA', 'cname' : 'Holy See (Vatican City State)'},
{'ccode' : 'HN', 'cname' : 'Honduras'},
{'ccode' : 'HK', 'cname' : 'Hong Kong'},
{'ccode' : 'HU', 'cname' : 'Hungary'},
{'ccode' : 'IS', 'cname' : 'Iceland'},
{'ccode' : 'IN', 'cname' : 'India'},
{'ccode' : 'ID', 'cname' : 'Indonesia'},
{'ccode' : 'IR', 'cname' : 'Iran, Islamic Republic Of'},
{'ccode' : 'IQ', 'cname' : 'Iraq'},
{'ccode' : 'IE', 'cname' : 'Ireland'},
{'ccode' : 'IM', 'cname' : 'Isle Of Man'},
{'ccode' : 'IL', 'cname' : 'Israel'},
{'ccode' : 'IT', 'cname' : 'Italy'},
{'ccode' : 'JM', 'cname' : 'Jamaica'},
{'ccode' : 'JP', 'cname' : 'Japan'},
{'ccode' : 'JE', 'cname' : 'Jersey'},
{'ccode' : 'JO', 'cname' : 'Jordan'},
{'ccode' : 'KZ', 'cname' : 'Kazakhstan'},
{'ccode' : 'KE', 'cname' : 'Kenya'},
{'ccode' : 'KI', 'cname' : 'Kiribati'},
{'ccode' : 'KR', 'cname' : 'Korea'},
{'ccode' : 'KW', 'cname' : 'Kuwait'},
{'ccode' : 'KG', 'cname' : 'Kyrgyzstan'},
{'ccode' : 'LA', 'cname' : 'Lao People's Democratic Republic'},
{'ccode' : 'LV', 'cname' : 'Latvia'},
{'ccode' : 'LB', 'cname' : 'Lebanon'},
{'ccode' : 'LS', 'cname' : 'Lesotho'},
{'ccode' : 'LR', 'cname' : 'Liberia'},
{'ccode' : 'LY', 'cname' : 'Libyan Arab Jamahiriya'},
{'ccode' : 'LI', 'cname' : 'Liechtenstein'},
{'ccode' : 'LT', 'cname' : 'Lithuania'},
{'ccode' : 'LU', 'cname' : 'Luxembourg'},
{'ccode' : 'MO', 'cname' : 'Macao'},
{'ccode' : 'MK', 'cname' : 'Macedonia'},
{'ccode' : 'MG', 'cname' : 'Madagascar'},
{'ccode' : 'MW', 'cname' : 'Malawi'},
{'ccode' : 'MY', 'cname' : 'Malaysia'},
{'ccode' : 'MV', 'cname' : 'Maldives'},
{'ccode' : 'ML', 'cname' : 'Mali'},
{'ccode' : 'MT', 'cname' : 'Malta'},
{'ccode' : 'MH', 'cname' : 'Marshall Islands'},
{'ccode' : 'MQ', 'cname' : 'Martinique'},
{'ccode' : 'MR', 'cname' : 'Mauritania'},
{'ccode' : 'MU', 'cname' : 'Mauritius'},
{'ccode' : 'YT', 'cname' : 'Mayotte'},
{'ccode' : 'MX', 'cname' : 'Mexico'},
{'ccode' : 'FM', 'cname' : 'Micronesia, Federated States Of'},
{'ccode' : 'MD', 'cname' : 'Moldova'},
{'ccode' : 'MC', 'cname' : 'Monaco'},
{'ccode' : 'MN', 'cname' : 'Mongolia'},
{'ccode' : 'ME', 'cname' : 'Montenegro'},
{'ccode' : 'MS', 'cname' : 'Montserrat'},
{'ccode' : 'MA', 'cname' : 'Morocco'},
{'ccode' : 'MZ', 'cname' : 'Mozambique'},
{'ccode' : 'MM', 'cname' : 'Myanmar'},
{'ccode' : 'NA', 'cname' : 'Namibia'},
{'ccode' : 'NR', 'cname' : 'Nauru'},
{'ccode' : 'NP', 'cname' : 'Nepal'},
{'ccode' : 'NL', 'cname' : 'Netherlands'},
{'ccode' : 'AN', 'cname' : 'Netherlands Antilles'},
{'ccode' : 'NC', 'cname' : 'New Caledonia'},
{'ccode' : 'NZ', 'cname' : 'New Zealand'},
{'ccode' : 'NI', 'cname' : 'Nicaragua'},
{'ccode' : 'NE', 'cname' : 'Niger'},
{'ccode' : 'NG', 'cname' : 'Nigeria'},
{'ccode' : 'NU', 'cname' : 'Niue'},
{'ccode' : 'NF', 'cname' : 'Norfolk Island'},
{'ccode' : 'MP', 'cname' : 'Northern Mariana Islands'},
{'ccode' : 'NO', 'cname' : 'Norway'},
{'ccode' : 'OM', 'cname' : 'Oman'},
{'ccode' : 'PK', 'cname' : 'Pakistan'},
{'ccode' : 'PW', 'cname' : 'Palau'},
{'ccode' : 'PS', 'cname' : 'Palestinian Territory, Occupied'},
{'ccode' : 'PA', 'cname' : 'Panama'},
{'ccode' : 'PG', 'cname' : 'Papua New Guinea'},
{'ccode' : 'PY', 'cname' : 'Paraguay'},
{'ccode' : 'PE', 'cname' : 'Peru'},
{'ccode' : 'PH', 'cname' : 'Philippines'},
{'ccode' : 'PN', 'cname' : 'Pitcairn'},
{'ccode' : 'PL', 'cname' : 'Poland'},
{'ccode' : 'PT', 'cname' : 'Portugal'},
{'ccode' : 'PR', 'cname' : 'Puerto Rico'},
{'ccode' : 'QA', 'cname' : 'Qatar'},
{'ccode' : 'RE', 'cname' : 'Reunion'},
{'ccode' : 'RO', 'cname' : 'Romania'},
{'ccode' : 'RU', 'cname' : 'Russian Federation'},
{'ccode' : 'RW', 'cname' : 'Rwanda'},
{'ccode' : 'BL', 'cname' : 'Saint Barthelemy'},
{'ccode' : 'SH', 'cname' : 'Saint Helena'},
{'ccode' : 'KN', 'cname' : 'Saint Kitts And Nevis'},
{'ccode' : 'LC', 'cname' : 'Saint Lucia'},
{'ccode' : 'MF', 'cname' : 'Saint Martin'},
{'ccode' : 'PM', 'cname' : 'Saint Pierre And Miquelon'},
{'ccode' : 'VC', 'cname' : 'Saint Vincent And Grenadines'},
{'ccode' : 'WS', 'cname' : 'Samoa'},
{'ccode' : 'SM', 'cname' : 'San Marino'},
{'ccode' : 'ST', 'cname' : 'Sao Tome And Principe'},
{'ccode' : 'SA', 'cname' : 'Saudi Arabia'},
{'ccode' : 'SN', 'cname' : 'Senegal'},
{'ccode' : 'RS', 'cname' : 'Serbia'},
{'ccode' : 'SC', 'cname' : 'Seychelles'},
{'ccode' : 'SL', 'cname' : 'Sierra Leone'},
{'ccode' : 'SG', 'cname' : 'Singapore'},
{'ccode' : 'SK', 'cname' : 'Slovakia'},
{'ccode' : 'SI', 'cname' : 'Slovenia'},
{'ccode' : 'SB', 'cname' : 'Solomon Islands'},
{'ccode' : 'SO', 'cname' : 'Somalia'},
{'ccode' : 'ZA', 'cname' : 'South Africa'},
{'ccode' : 'GS', 'cname' : 'South Georgia And Sandwich Isl.'},
{'ccode' : 'ES', 'cname' : 'Spain'},
{'ccode' : 'LK', 'cname' : 'Sri Lanka'},
{'ccode' : 'SD', 'cname' : 'Sudan'},
{'ccode' : 'SR', 'cname' : 'Suriname'},
{'ccode' : 'SJ', 'cname' : 'Svalbard And Jan Mayen'},
{'ccode' : 'SZ', 'cname' : 'Swaziland'},
{'ccode' : 'SE', 'cname' : 'Sweden'},
{'ccode' : 'CH', 'cname' : 'Switzerland'},
{'ccode' : 'SY', 'cname' : 'Syrian Arab Republic'},
{'ccode' : 'TW', 'cname' : 'Taiwan'},
{'ccode' : 'TJ', 'cname' : 'Tajikistan'},
{'ccode' : 'TZ', 'cname' : 'Tanzania'},
{'ccode' : 'TH', 'cname' : 'Thailand'},
{'ccode' : 'TL', 'cname' : 'Timor-Leste'},
{'ccode' : 'TG', 'cname' : 'Togo'},
{'ccode' : 'TK', 'cname' : 'Tokelau'},
{'ccode' : 'TO', 'cname' : 'Tonga'},
{'ccode' : 'TT', 'cname' : 'Trinidad And Tobago'},
{'ccode' : 'TN', 'cname' : 'Tunisia'},
{'ccode' : 'TR', 'cname' : 'Turkey'},
{'ccode' : 'TM', 'cname' : 'Turkmenistan'},
{'ccode' : 'TC', 'cname' : 'Turks And Caicos Islands'},
{'ccode' : 'TV', 'cname' : 'Tuvalu'},
{'ccode' : 'UG', 'cname' : 'Uganda'},
{'ccode' : 'UA', 'cname' : 'Ukraine'},
{'ccode' : 'AE', 'cname' : 'United Arab Emirates'},
{'ccode' : 'GB', 'cname' : 'United Kingdom'},
{'ccode' : 'US', 'cname' : 'United States'},
{'ccode' : 'UM', 'cname' : 'United States Outlying Islands'},
{'ccode' : 'UY', 'cname' : 'Uruguay'},
{'ccode' : 'UZ', 'cname' : 'Uzbekistan'},
{'ccode' : 'VU', 'cname' : 'Vanuatu'},
{'ccode' : 'VE', 'cname' : 'Venezuela'},
{'ccode' : 'VN', 'cname' : 'Viet Nam'},
{'ccode' : 'VG', 'cname' : 'Virgin Islands, British'},
{'ccode' : 'VI', 'cname' : 'Virgin Islands, U.S.'},
{'ccode' : 'WF', 'cname' : 'Wallis And Futuna'},
{'ccode' : 'EH', 'cname' : 'Western Sahara'},
{'ccode' : 'YE', 'cname' : 'Yemen'},
{'ccode' : 'ZM', 'cname' : 'Zambia'},
{'ccode' : 'ZW', 'cname' : 'Zimbabwe'}
];

//Returns the ISO Country Code for the 
 // given CountryName
return function (countryName) {
  for(var prop in isoCountries1){
      if(isoCountries1.hasOwnProperty(prop)){
          if(isoCountries1[prop]['cname'] === countryName) {
              return isoCountries1[prop]['ccode'];
              break;
          }
      }
  }
}

});

philsam commented Aug 7, 2016

For Angular JS users: Use it as a Service

$scope.CountryName = "Nigeria";

CountryIso($scope.CountryName)

// Returns the ISO Country Code for the
// given CountryName
angular.module('YourApp').factory('CountryIso', function() {
var isoCountries1 = [
{'ccode' : 'AF', 'cname' : 'Afghanistan'},
{'ccode' : 'AX', 'cname' : 'Aland Islands'},
{'ccode' : 'AL', 'cname' : 'Albania'},
{'ccode' : 'DZ', 'cname' : 'Algeria'},
{'ccode' : 'AS', 'cname' : 'American Samoa'},
{'ccode' : 'AD', 'cname' : 'Andorra'},
{'ccode' : 'AO', 'cname' : 'Angola'},
{'ccode' : 'AI', 'cname' : 'Anguilla'},
{'ccode' : 'AQ', 'cname' : 'Antarctica'},
{'ccode' : 'AG', 'cname' : 'Antigua And Barbuda'},
{'ccode' : 'AR', 'cname' : 'Argentina'},
{'ccode' : 'AM', 'cname' : 'Armenia'},
{'ccode' : 'AW', 'cname' : 'Aruba'},
{'ccode' : 'AU', 'cname' : 'Australia'},
{'ccode' : 'AT', 'cname' : 'Austria'},
{'ccode' : 'AZ', 'cname' : 'Azerbaijan'},
{'ccode' : 'BS', 'cname' : 'Bahamas'},
{'ccode' : 'BH', 'cname' : 'Bahrain'},
{'ccode' : 'BD', 'cname' : 'Bangladesh'},
{'ccode' : 'BB', 'cname' : 'Barbados'},
{'ccode' : 'BY', 'cname' : 'Belarus'},
{'ccode' : 'BE', 'cname' : 'Belgium'},
{'ccode' : 'BZ', 'cname' : 'Belize'},
{'ccode' : 'BJ', 'cname' : 'Benin'},
{'ccode' : 'BM', 'cname' : 'Bermuda'},
{'ccode' : 'BT', 'cname' : 'Bhutan'},
{'ccode' : 'BO', 'cname' : 'Bolivia'},
{'ccode' : 'BA', 'cname' : 'Bosnia And Herzegovina'},
{'ccode' : 'BW', 'cname' : 'Botswana'},
{'ccode' : 'BV', 'cname' : 'Bouvet Island'},
{'ccode' : 'BR', 'cname' : 'Brazil'},
{'ccode' : 'IO', 'cname' : 'British Indian Ocean Territory'},
{'ccode' : 'BN', 'cname' : 'Brunei Darussalam'},
{'ccode' : 'BG', 'cname' : 'Bulgaria'},
{'ccode' : 'BF', 'cname' : 'Burkina Faso'},
{'ccode' : 'BI', 'cname' : 'Burundi'},
{'ccode' : 'KH', 'cname' : 'Cambodia'},
{'ccode' : 'CM', 'cname' : 'Cameroon'},
{'ccode' : 'CA', 'cname' : 'Canada'},
{'ccode' : 'CV', 'cname' : 'Cape Verde'},
{'ccode' : 'KY', 'cname' : 'Cayman Islands'},
{'ccode' : 'CF', 'cname' : 'Central African Republic'},
{'ccode' : 'TD', 'cname' : 'Chad'},
{'ccode' : 'CL', 'cname' : 'Chile'},
{'ccode' : 'CN', 'cname' : 'China'},
{'ccode' : 'CX', 'cname' : 'Christmas Island'},
{'ccode' : 'CC', 'cname' : 'Cocos (Keeling) Islands'},
{'ccode' : 'CO', 'cname' : 'Colombia'},
{'ccode' : 'KM', 'cname' : 'Comoros'},
{'ccode' : 'CG', 'cname' : 'Congo'},
{'ccode' : 'CD', 'cname' : 'Congo, Democratic Republic'},
{'ccode' : 'CK', 'cname' : 'Cook Islands'},
{'ccode' : 'CR', 'cname' : 'Costa Rica'},
{'ccode' : 'CI', 'cname' : 'Cote D'Ivoire'},
{'ccode' : 'HR', 'cname' : 'Croatia'},
{'ccode' : 'CU', 'cname' : 'Cuba'},
{'ccode' : 'CY', 'cname' : 'Cyprus'},
{'ccode' : 'CZ', 'cname' : 'Czech Republic'},
{'ccode' : 'DK', 'cname' : 'Denmark'},
{'ccode' : 'DJ', 'cname' : 'Djibouti'},
{'ccode' : 'DM', 'cname' : 'Dominica'},
{'ccode' : 'DO', 'cname' : 'Dominican Republic'},
{'ccode' : 'EC', 'cname' : 'Ecuador'},
{'ccode' : 'EG', 'cname' : 'Egypt'},
{'ccode' : 'SV', 'cname' : 'El Salvador'},
{'ccode' : 'GQ', 'cname' : 'Equatorial Guinea'},
{'ccode' : 'ER', 'cname' : 'Eritrea'},
{'ccode' : 'EE', 'cname' : 'Estonia'},
{'ccode' : 'ET', 'cname' : 'Ethiopia'},
{'ccode' : 'FK', 'cname' : 'Falkland Islands (Malvinas)'},
{'ccode' : 'FO', 'cname' : 'Faroe Islands'},
{'ccode' : 'FJ', 'cname' : 'Fiji'},
{'ccode' : 'FI', 'cname' : 'Finland'},
{'ccode' : 'FR', 'cname' : 'France'},
{'ccode' : 'GF', 'cname' : 'French Guiana'},
{'ccode' : 'PF', 'cname' : 'French Polynesia'},
{'ccode' : 'TF', 'cname' : 'French Southern Territories'},
{'ccode' : 'GA', 'cname' : 'Gabon'},
{'ccode' : 'GM', 'cname' : 'Gambia'},
{'ccode' : 'GE', 'cname' : 'Georgia'},
{'ccode' : 'DE', 'cname' : 'Germany'},
{'ccode' : 'GH', 'cname' : 'Ghana'},
{'ccode' : 'GI', 'cname' : 'Gibraltar'},
{'ccode' : 'GR', 'cname' : 'Greece'},
{'ccode' : 'GL', 'cname' : 'Greenland'},
{'ccode' : 'GD', 'cname' : 'Grenada'},
{'ccode' : 'GP', 'cname' : 'Guadeloupe'},
{'ccode' : 'GU', 'cname' : 'Guam'},
{'ccode' : 'GT', 'cname' : 'Guatemala'},
{'ccode' : 'GG', 'cname' : 'Guernsey'},
{'ccode' : 'GN', 'cname' : 'Guinea'},
{'ccode' : 'GW', 'cname' : 'Guinea-Bissau'},
{'ccode' : 'GY', 'cname' : 'Guyana'},
{'ccode' : 'HT', 'cname' : 'Haiti'},
{'ccode' : 'HM', 'cname' : 'Heard Island & Mcdonald Islands'},
{'ccode' : 'VA', 'cname' : 'Holy See (Vatican City State)'},
{'ccode' : 'HN', 'cname' : 'Honduras'},
{'ccode' : 'HK', 'cname' : 'Hong Kong'},
{'ccode' : 'HU', 'cname' : 'Hungary'},
{'ccode' : 'IS', 'cname' : 'Iceland'},
{'ccode' : 'IN', 'cname' : 'India'},
{'ccode' : 'ID', 'cname' : 'Indonesia'},
{'ccode' : 'IR', 'cname' : 'Iran, Islamic Republic Of'},
{'ccode' : 'IQ', 'cname' : 'Iraq'},
{'ccode' : 'IE', 'cname' : 'Ireland'},
{'ccode' : 'IM', 'cname' : 'Isle Of Man'},
{'ccode' : 'IL', 'cname' : 'Israel'},
{'ccode' : 'IT', 'cname' : 'Italy'},
{'ccode' : 'JM', 'cname' : 'Jamaica'},
{'ccode' : 'JP', 'cname' : 'Japan'},
{'ccode' : 'JE', 'cname' : 'Jersey'},
{'ccode' : 'JO', 'cname' : 'Jordan'},
{'ccode' : 'KZ', 'cname' : 'Kazakhstan'},
{'ccode' : 'KE', 'cname' : 'Kenya'},
{'ccode' : 'KI', 'cname' : 'Kiribati'},
{'ccode' : 'KR', 'cname' : 'Korea'},
{'ccode' : 'KW', 'cname' : 'Kuwait'},
{'ccode' : 'KG', 'cname' : 'Kyrgyzstan'},
{'ccode' : 'LA', 'cname' : 'Lao People's Democratic Republic'},
{'ccode' : 'LV', 'cname' : 'Latvia'},
{'ccode' : 'LB', 'cname' : 'Lebanon'},
{'ccode' : 'LS', 'cname' : 'Lesotho'},
{'ccode' : 'LR', 'cname' : 'Liberia'},
{'ccode' : 'LY', 'cname' : 'Libyan Arab Jamahiriya'},
{'ccode' : 'LI', 'cname' : 'Liechtenstein'},
{'ccode' : 'LT', 'cname' : 'Lithuania'},
{'ccode' : 'LU', 'cname' : 'Luxembourg'},
{'ccode' : 'MO', 'cname' : 'Macao'},
{'ccode' : 'MK', 'cname' : 'Macedonia'},
{'ccode' : 'MG', 'cname' : 'Madagascar'},
{'ccode' : 'MW', 'cname' : 'Malawi'},
{'ccode' : 'MY', 'cname' : 'Malaysia'},
{'ccode' : 'MV', 'cname' : 'Maldives'},
{'ccode' : 'ML', 'cname' : 'Mali'},
{'ccode' : 'MT', 'cname' : 'Malta'},
{'ccode' : 'MH', 'cname' : 'Marshall Islands'},
{'ccode' : 'MQ', 'cname' : 'Martinique'},
{'ccode' : 'MR', 'cname' : 'Mauritania'},
{'ccode' : 'MU', 'cname' : 'Mauritius'},
{'ccode' : 'YT', 'cname' : 'Mayotte'},
{'ccode' : 'MX', 'cname' : 'Mexico'},
{'ccode' : 'FM', 'cname' : 'Micronesia, Federated States Of'},
{'ccode' : 'MD', 'cname' : 'Moldova'},
{'ccode' : 'MC', 'cname' : 'Monaco'},
{'ccode' : 'MN', 'cname' : 'Mongolia'},
{'ccode' : 'ME', 'cname' : 'Montenegro'},
{'ccode' : 'MS', 'cname' : 'Montserrat'},
{'ccode' : 'MA', 'cname' : 'Morocco'},
{'ccode' : 'MZ', 'cname' : 'Mozambique'},
{'ccode' : 'MM', 'cname' : 'Myanmar'},
{'ccode' : 'NA', 'cname' : 'Namibia'},
{'ccode' : 'NR', 'cname' : 'Nauru'},
{'ccode' : 'NP', 'cname' : 'Nepal'},
{'ccode' : 'NL', 'cname' : 'Netherlands'},
{'ccode' : 'AN', 'cname' : 'Netherlands Antilles'},
{'ccode' : 'NC', 'cname' : 'New Caledonia'},
{'ccode' : 'NZ', 'cname' : 'New Zealand'},
{'ccode' : 'NI', 'cname' : 'Nicaragua'},
{'ccode' : 'NE', 'cname' : 'Niger'},
{'ccode' : 'NG', 'cname' : 'Nigeria'},
{'ccode' : 'NU', 'cname' : 'Niue'},
{'ccode' : 'NF', 'cname' : 'Norfolk Island'},
{'ccode' : 'MP', 'cname' : 'Northern Mariana Islands'},
{'ccode' : 'NO', 'cname' : 'Norway'},
{'ccode' : 'OM', 'cname' : 'Oman'},
{'ccode' : 'PK', 'cname' : 'Pakistan'},
{'ccode' : 'PW', 'cname' : 'Palau'},
{'ccode' : 'PS', 'cname' : 'Palestinian Territory, Occupied'},
{'ccode' : 'PA', 'cname' : 'Panama'},
{'ccode' : 'PG', 'cname' : 'Papua New Guinea'},
{'ccode' : 'PY', 'cname' : 'Paraguay'},
{'ccode' : 'PE', 'cname' : 'Peru'},
{'ccode' : 'PH', 'cname' : 'Philippines'},
{'ccode' : 'PN', 'cname' : 'Pitcairn'},
{'ccode' : 'PL', 'cname' : 'Poland'},
{'ccode' : 'PT', 'cname' : 'Portugal'},
{'ccode' : 'PR', 'cname' : 'Puerto Rico'},
{'ccode' : 'QA', 'cname' : 'Qatar'},
{'ccode' : 'RE', 'cname' : 'Reunion'},
{'ccode' : 'RO', 'cname' : 'Romania'},
{'ccode' : 'RU', 'cname' : 'Russian Federation'},
{'ccode' : 'RW', 'cname' : 'Rwanda'},
{'ccode' : 'BL', 'cname' : 'Saint Barthelemy'},
{'ccode' : 'SH', 'cname' : 'Saint Helena'},
{'ccode' : 'KN', 'cname' : 'Saint Kitts And Nevis'},
{'ccode' : 'LC', 'cname' : 'Saint Lucia'},
{'ccode' : 'MF', 'cname' : 'Saint Martin'},
{'ccode' : 'PM', 'cname' : 'Saint Pierre And Miquelon'},
{'ccode' : 'VC', 'cname' : 'Saint Vincent And Grenadines'},
{'ccode' : 'WS', 'cname' : 'Samoa'},
{'ccode' : 'SM', 'cname' : 'San Marino'},
{'ccode' : 'ST', 'cname' : 'Sao Tome And Principe'},
{'ccode' : 'SA', 'cname' : 'Saudi Arabia'},
{'ccode' : 'SN', 'cname' : 'Senegal'},
{'ccode' : 'RS', 'cname' : 'Serbia'},
{'ccode' : 'SC', 'cname' : 'Seychelles'},
{'ccode' : 'SL', 'cname' : 'Sierra Leone'},
{'ccode' : 'SG', 'cname' : 'Singapore'},
{'ccode' : 'SK', 'cname' : 'Slovakia'},
{'ccode' : 'SI', 'cname' : 'Slovenia'},
{'ccode' : 'SB', 'cname' : 'Solomon Islands'},
{'ccode' : 'SO', 'cname' : 'Somalia'},
{'ccode' : 'ZA', 'cname' : 'South Africa'},
{'ccode' : 'GS', 'cname' : 'South Georgia And Sandwich Isl.'},
{'ccode' : 'ES', 'cname' : 'Spain'},
{'ccode' : 'LK', 'cname' : 'Sri Lanka'},
{'ccode' : 'SD', 'cname' : 'Sudan'},
{'ccode' : 'SR', 'cname' : 'Suriname'},
{'ccode' : 'SJ', 'cname' : 'Svalbard And Jan Mayen'},
{'ccode' : 'SZ', 'cname' : 'Swaziland'},
{'ccode' : 'SE', 'cname' : 'Sweden'},
{'ccode' : 'CH', 'cname' : 'Switzerland'},
{'ccode' : 'SY', 'cname' : 'Syrian Arab Republic'},
{'ccode' : 'TW', 'cname' : 'Taiwan'},
{'ccode' : 'TJ', 'cname' : 'Tajikistan'},
{'ccode' : 'TZ', 'cname' : 'Tanzania'},
{'ccode' : 'TH', 'cname' : 'Thailand'},
{'ccode' : 'TL', 'cname' : 'Timor-Leste'},
{'ccode' : 'TG', 'cname' : 'Togo'},
{'ccode' : 'TK', 'cname' : 'Tokelau'},
{'ccode' : 'TO', 'cname' : 'Tonga'},
{'ccode' : 'TT', 'cname' : 'Trinidad And Tobago'},
{'ccode' : 'TN', 'cname' : 'Tunisia'},
{'ccode' : 'TR', 'cname' : 'Turkey'},
{'ccode' : 'TM', 'cname' : 'Turkmenistan'},
{'ccode' : 'TC', 'cname' : 'Turks And Caicos Islands'},
{'ccode' : 'TV', 'cname' : 'Tuvalu'},
{'ccode' : 'UG', 'cname' : 'Uganda'},
{'ccode' : 'UA', 'cname' : 'Ukraine'},
{'ccode' : 'AE', 'cname' : 'United Arab Emirates'},
{'ccode' : 'GB', 'cname' : 'United Kingdom'},
{'ccode' : 'US', 'cname' : 'United States'},
{'ccode' : 'UM', 'cname' : 'United States Outlying Islands'},
{'ccode' : 'UY', 'cname' : 'Uruguay'},
{'ccode' : 'UZ', 'cname' : 'Uzbekistan'},
{'ccode' : 'VU', 'cname' : 'Vanuatu'},
{'ccode' : 'VE', 'cname' : 'Venezuela'},
{'ccode' : 'VN', 'cname' : 'Viet Nam'},
{'ccode' : 'VG', 'cname' : 'Virgin Islands, British'},
{'ccode' : 'VI', 'cname' : 'Virgin Islands, U.S.'},
{'ccode' : 'WF', 'cname' : 'Wallis And Futuna'},
{'ccode' : 'EH', 'cname' : 'Western Sahara'},
{'ccode' : 'YE', 'cname' : 'Yemen'},
{'ccode' : 'ZM', 'cname' : 'Zambia'},
{'ccode' : 'ZW', 'cname' : 'Zimbabwe'}
];

//Returns the ISO Country Code for the 
 // given CountryName
return function (countryName) {
  for(var prop in isoCountries1){
      if(isoCountries1.hasOwnProperty(prop)){
          if(isoCountries1[prop]['cname'] === countryName) {
              return isoCountries1[prop]['ccode'];
              break;
          }
      }
  }
}

});

@tmrk

This comment has been minimized.

Show comment
Hide comment
@tmrk

tmrk Aug 19, 2016

Thanks for this idea!

I needed some more details (such as regions and continents), so I created another one, see here: https://gist.github.com/tmrk/4aa3cf285360526a98b2115d63e0cafd

tmrk commented Aug 19, 2016

Thanks for this idea!

I needed some more details (such as regions and continents), so I created another one, see here: https://gist.github.com/tmrk/4aa3cf285360526a98b2115d63e0cafd

@1mike12

This comment has been minimized.

Show comment
Hide comment
@1mike12

1mike12 Dec 30, 2016

in reverse, IE using some geocoders without short 2 letter codes:

    var isoCountries = {
        'Afghanistan': 'AF',
        'Aland Islands': 'AX',
        'Albania': 'AL',
        'Algeria': 'DZ',
        'American Samoa': 'AS',
        'Andorra': 'AD',
        'Angola': 'AO',
        'Anguilla': 'AI',
        'Antarctica': 'AQ',
        'Antigua And Barbuda': 'AG',
        'Argentina': 'AR',
        'Armenia': 'AM',
        'Aruba': 'AW',
        'Australia': 'AU',
        'Austria': 'AT',
        'Azerbaijan': 'AZ',
        'Bahamas': 'BS',
        'Bahrain': 'BH',
        'Bangladesh': 'BD',
        'Barbados': 'BB',
        'Belarus': 'BY',
        'Belgium': 'BE',
        'Belize': 'BZ',
        'Benin': 'BJ',
        'Bermuda': 'BM',
        'Bhutan': 'BT',
        'Bolivia': 'BO',
        'Bosnia And Herzegovina': 'BA',
        'Botswana': 'BW',
        'Bouvet Island': 'BV',
        'Brazil': 'BR',
        'British Indian Ocean Territory': 'IO',
        'Brunei Darussalam': 'BN',
        'Bulgaria': 'BG',
        'Burkina Faso': 'BF',
        'Burundi': 'BI',
        'Cambodia': 'KH',
        'Cameroon': 'CM',
        'Canada': 'CA',
        'Cape Verde': 'CV',
        'Cayman Islands': 'KY',
        'Central African Republic': 'CF',
        'Chad': 'TD',
        'Chile': 'CL',
        'China': 'CN',
        'Christmas Island': 'CX',
        'Cocos (Keeling) Islands': 'CC',
        'Colombia': 'CO',
        'Comoros': 'KM',
        'Congo': 'CG',
        'Congo, Democratic Republic': 'CD',
        'Cook Islands': 'CK',
        'Costa Rica': 'CR',
        'Cote D\'Ivoire': 'CI',
        'Croatia': 'HR',
        'Cuba': 'CU',
        'Cyprus': 'CY',
        'Czech Republic': 'CZ',
        'Denmark': 'DK',
        'Djibouti': 'DJ',
        'Dominica': 'DM',
        'Dominican Republic': 'DO',
        'Ecuador': 'EC',
        'Egypt': 'EG',
        'El Salvador': 'SV',
        'Equatorial Guinea': 'GQ',
        'Eritrea': 'ER',
        'Estonia': 'EE',
        'Ethiopia': 'ET',
        'Falkland Islands': 'FK',
        'Faroe Islands': 'FO',
        'Fiji': 'FJ',
        'Finland': 'FI',
        'France': 'FR',
        'French Guiana': 'GF',
        'French Polynesia': 'PF',
        'French Southern Territories': 'TF',
        'Gabon': 'GA',
        'Gambia': 'GM',
        'Georgia': 'GE',
        'Germany': 'DE',
        'Ghana': 'GH',
        'Gibraltar': 'GI',
        'Greece': 'GR',
        'Greenland': 'GL',
        'Grenada': 'GD',
        'Guadeloupe': 'GP',
        'Guam': 'GU',
        'Guatemala': 'GT',
        'Guernsey': 'GG',
        'Guinea': 'GN',
        'Guinea-Bissau': 'GW',
        'Guyana': 'GY',
        'Haiti': 'HT',
        'Heard Island & Mcdonald Islands': 'HM',
        'Holy See (Vatican City State)': 'VA',
        'Honduras': 'HN',
        'Hong Kong': 'HK',
        'Hungary': 'HU',
        'Iceland': 'IS',
        'India': 'IN',
        'Indonesia': 'ID',
        'Iran, Islamic Republic Of': 'IR',
        'Iraq': 'IQ',
        'Ireland': 'IE',
        'Isle Of Man': 'IM',
        'Israel': 'IL',
        'Italy': 'IT',
        'Jamaica': 'JM',
        'Japan': 'JP',
        'Jersey': 'JE',
        'Jordan': 'JO',
        'Kazakhstan': 'KZ',
        'Kenya': 'KE',
        'Kiribati': 'KI',
        'Korea': 'KR',
        'Kuwait': 'KW',
        'Kyrgyzstan': 'KG',
        'Lao People\'s Democratic Republic': 'LA',
        'Latvia': 'LV',
        'Lebanon': 'LB',
        'Lesotho': 'LS',
        'Liberia': 'LR',
        'Libyan Arab Jamahiriya': 'LY',
        'Liechtenstein': 'LI',
        'Lithuania': 'LT',
        'Luxembourg': 'LU',
        'Macao': 'MO',
        'Macedonia': 'MK',
        'Madagascar': 'MG',
        'Malawi': 'MW',
        'Malaysia': 'MY',
        'Maldives': 'MV',
        'Mali': 'ML',
        'Malta': 'MT',
        'Marshall Islands': 'MH',
        'Martinique': 'MQ',
        'Mauritania': 'MR',
        'Mauritius': 'MU',
        'Mayotte': 'YT',
        'Mexico': 'MX',
        'Micronesia, Federated States Of': 'FM',
        'Moldova': 'MD',
        'Monaco': 'MC',
        'Mongolia': 'MN',
        'Montenegro': 'ME',
        'Montserrat': 'MS',
        'Morocco': 'MA',
        'Mozambique': 'MZ',
        'Myanmar': 'MM',
        'Namibia': 'NA',
        'Nauru': 'NR',
        'Nepal': 'NP',
        'Netherlands': 'NL',
        'Netherlands Antilles': 'AN',
        'New Caledonia': 'NC',
        'New Zealand': 'NZ',
        'Nicaragua': 'NI',
        'Niger': 'NE',
        'Nigeria': 'NG',
        'Niue': 'NU',
        'Norfolk Island': 'NF',
        'Northern Mariana Islands': 'MP',
        'Norway': 'NO',
        'Oman': 'OM',
        'Pakistan': 'PK',
        'Palau': 'PW',
        'Palestinian Territory, Occupied': 'PS',
        'Panama': 'PA',
        'Papua New Guinea': 'PG',
        'Paraguay': 'PY',
        'Peru': 'PE',
        'Philippines': 'PH',
        'Pitcairn': 'PN',
        'Poland': 'PL',
        'Portugal': 'PT',
        'Puerto Rico': 'PR',
        'Qatar': 'QA',
        'Reunion': 'RE',
        'Romania': 'RO',
        'Russian Federation': 'RU',
        'Rwanda': 'RW',
        'Saint Barthelemy': 'BL',
        'Saint Helena': 'SH',
        'Saint Kitts And Nevis': 'KN',
        'Saint Lucia': 'LC',
        'Saint Martin': 'MF',
        'Saint Pierre And Miquelon': 'PM',
        'Saint Vincent And Grenadines': 'VC',
        'Samoa': 'WS',
        'San Marino': 'SM',
        'Sao Tome And Principe': 'ST',
        'Saudi Arabia': 'SA',
        'Senegal': 'SN',
        'Serbia': 'RS',
        'Seychelles': 'SC',
        'Sierra Leone': 'SL',
        'Singapore': 'SG',
        'Slovakia': 'SK',
        'Slovenia': 'SI',
        'Solomon Islands': 'SB',
        'Somalia': 'SO',
        'South Africa': 'ZA',
        'South Georgia And Sandwich Isl.': 'GS',
        'Spain': 'ES',
        'Sri Lanka': 'LK',
        'Sudan': 'SD',
        'Suriname': 'SR',
        'Svalbard And Jan Mayen': 'SJ',
        'Swaziland': 'SZ',
        'Sweden': 'SE',
        'Switzerland': 'CH',
        'Syrian Arab Republic': 'SY',
        'Taiwan': 'TW',
        'Tajikistan': 'TJ',
        'Tanzania': 'TZ',
        'Thailand': 'TH',
        'Timor-Leste': 'TL',
        'Togo': 'TG',
        'Tokelau': 'TK',
        'Tonga': 'TO',
        'Trinidad And Tobago': 'TT',
        'Tunisia': 'TN',
        'Turkey': 'TR',
        'Turkmenistan': 'TM',
        'Turks And Caicos Islands': 'TC',
        'Tuvalu': 'TV',
        'Uganda': 'UG',
        'Ukraine': 'UA',
        'United Arab Emirates': 'AE',
        'United Kingdom': 'GB',
        'United States': 'US',
        'United States Outlying Islands': 'UM',
        'Uruguay': 'UY',
        'Uzbekistan': 'UZ',
        'Vanuatu': 'VU',
        'Venezuela': 'VE',
        'Vietnam': 'VN',
        'Virgin Islands, British': 'VG',
        'Virgin Islands, U.S.': 'VI',
        'Wallis And Futuna': 'WF',
        'Western Sahara': 'EH',
        'Yemen': 'YE',
        'Zambia': 'ZM',
        'Zimbabwe': 'ZW'
    };

1mike12 commented Dec 30, 2016

in reverse, IE using some geocoders without short 2 letter codes:

    var isoCountries = {
        'Afghanistan': 'AF',
        'Aland Islands': 'AX',
        'Albania': 'AL',
        'Algeria': 'DZ',
        'American Samoa': 'AS',
        'Andorra': 'AD',
        'Angola': 'AO',
        'Anguilla': 'AI',
        'Antarctica': 'AQ',
        'Antigua And Barbuda': 'AG',
        'Argentina': 'AR',
        'Armenia': 'AM',
        'Aruba': 'AW',
        'Australia': 'AU',
        'Austria': 'AT',
        'Azerbaijan': 'AZ',
        'Bahamas': 'BS',
        'Bahrain': 'BH',
        'Bangladesh': 'BD',
        'Barbados': 'BB',
        'Belarus': 'BY',
        'Belgium': 'BE',
        'Belize': 'BZ',
        'Benin': 'BJ',
        'Bermuda': 'BM',
        'Bhutan': 'BT',
        'Bolivia': 'BO',
        'Bosnia And Herzegovina': 'BA',
        'Botswana': 'BW',
        'Bouvet Island': 'BV',
        'Brazil': 'BR',
        'British Indian Ocean Territory': 'IO',
        'Brunei Darussalam': 'BN',
        'Bulgaria': 'BG',
        'Burkina Faso': 'BF',
        'Burundi': 'BI',
        'Cambodia': 'KH',
        'Cameroon': 'CM',
        'Canada': 'CA',
        'Cape Verde': 'CV',
        'Cayman Islands': 'KY',
        'Central African Republic': 'CF',
        'Chad': 'TD',
        'Chile': 'CL',
        'China': 'CN',
        'Christmas Island': 'CX',
        'Cocos (Keeling) Islands': 'CC',
        'Colombia': 'CO',
        'Comoros': 'KM',
        'Congo': 'CG',
        'Congo, Democratic Republic': 'CD',
        'Cook Islands': 'CK',
        'Costa Rica': 'CR',
        'Cote D\'Ivoire': 'CI',
        'Croatia': 'HR',
        'Cuba': 'CU',
        'Cyprus': 'CY',
        'Czech Republic': 'CZ',
        'Denmark': 'DK',
        'Djibouti': 'DJ',
        'Dominica': 'DM',
        'Dominican Republic': 'DO',
        'Ecuador': 'EC',
        'Egypt': 'EG',
        'El Salvador': 'SV',
        'Equatorial Guinea': 'GQ',
        'Eritrea': 'ER',
        'Estonia': 'EE',
        'Ethiopia': 'ET',
        'Falkland Islands': 'FK',
        'Faroe Islands': 'FO',
        'Fiji': 'FJ',
        'Finland': 'FI',
        'France': 'FR',
        'French Guiana': 'GF',
        'French Polynesia': 'PF',
        'French Southern Territories': 'TF',
        'Gabon': 'GA',
        'Gambia': 'GM',
        'Georgia': 'GE',
        'Germany': 'DE',
        'Ghana': 'GH',
        'Gibraltar': 'GI',
        'Greece': 'GR',
        'Greenland': 'GL',
        'Grenada': 'GD',
        'Guadeloupe': 'GP',
        'Guam': 'GU',
        'Guatemala': 'GT',
        'Guernsey': 'GG',
        'Guinea': 'GN',
        'Guinea-Bissau': 'GW',
        'Guyana': 'GY',
        'Haiti': 'HT',
        'Heard Island & Mcdonald Islands': 'HM',
        'Holy See (Vatican City State)': 'VA',
        'Honduras': 'HN',
        'Hong Kong': 'HK',
        'Hungary': 'HU',
        'Iceland': 'IS',
        'India': 'IN',
        'Indonesia': 'ID',
        'Iran, Islamic Republic Of': 'IR',
        'Iraq': 'IQ',
        'Ireland': 'IE',
        'Isle Of Man': 'IM',
        'Israel': 'IL',
        'Italy': 'IT',
        'Jamaica': 'JM',
        'Japan': 'JP',
        'Jersey': 'JE',
        'Jordan': 'JO',
        'Kazakhstan': 'KZ',
        'Kenya': 'KE',
        'Kiribati': 'KI',
        'Korea': 'KR',
        'Kuwait': 'KW',
        'Kyrgyzstan': 'KG',
        'Lao People\'s Democratic Republic': 'LA',
        'Latvia': 'LV',
        'Lebanon': 'LB',
        'Lesotho': 'LS',
        'Liberia': 'LR',
        'Libyan Arab Jamahiriya': 'LY',
        'Liechtenstein': 'LI',
        'Lithuania': 'LT',
        'Luxembourg': 'LU',
        'Macao': 'MO',
        'Macedonia': 'MK',
        'Madagascar': 'MG',
        'Malawi': 'MW',
        'Malaysia': 'MY',
        'Maldives': 'MV',
        'Mali': 'ML',
        'Malta': 'MT',
        'Marshall Islands': 'MH',
        'Martinique': 'MQ',
        'Mauritania': 'MR',
        'Mauritius': 'MU',
        'Mayotte': 'YT',
        'Mexico': 'MX',
        'Micronesia, Federated States Of': 'FM',
        'Moldova': 'MD',
        'Monaco': 'MC',
        'Mongolia': 'MN',
        'Montenegro': 'ME',
        'Montserrat': 'MS',
        'Morocco': 'MA',
        'Mozambique': 'MZ',
        'Myanmar': 'MM',
        'Namibia': 'NA',
        'Nauru': 'NR',
        'Nepal': 'NP',
        'Netherlands': 'NL',
        'Netherlands Antilles': 'AN',
        'New Caledonia': 'NC',
        'New Zealand': 'NZ',
        'Nicaragua': 'NI',
        'Niger': 'NE',
        'Nigeria': 'NG',
        'Niue': 'NU',
        'Norfolk Island': 'NF',
        'Northern Mariana Islands': 'MP',
        'Norway': 'NO',
        'Oman': 'OM',
        'Pakistan': 'PK',
        'Palau': 'PW',
        'Palestinian Territory, Occupied': 'PS',
        'Panama': 'PA',
        'Papua New Guinea': 'PG',
        'Paraguay': 'PY',
        'Peru': 'PE',
        'Philippines': 'PH',
        'Pitcairn': 'PN',
        'Poland': 'PL',
        'Portugal': 'PT',
        'Puerto Rico': 'PR',
        'Qatar': 'QA',
        'Reunion': 'RE',
        'Romania': 'RO',
        'Russian Federation': 'RU',
        'Rwanda': 'RW',
        'Saint Barthelemy': 'BL',
        'Saint Helena': 'SH',
        'Saint Kitts And Nevis': 'KN',
        'Saint Lucia': 'LC',
        'Saint Martin': 'MF',
        'Saint Pierre And Miquelon': 'PM',
        'Saint Vincent And Grenadines': 'VC',
        'Samoa': 'WS',
        'San Marino': 'SM',
        'Sao Tome And Principe': 'ST',
        'Saudi Arabia': 'SA',
        'Senegal': 'SN',
        'Serbia': 'RS',
        'Seychelles': 'SC',
        'Sierra Leone': 'SL',
        'Singapore': 'SG',
        'Slovakia': 'SK',
        'Slovenia': 'SI',
        'Solomon Islands': 'SB',
        'Somalia': 'SO',
        'South Africa': 'ZA',
        'South Georgia And Sandwich Isl.': 'GS',
        'Spain': 'ES',
        'Sri Lanka': 'LK',
        'Sudan': 'SD',
        'Suriname': 'SR',
        'Svalbard And Jan Mayen': 'SJ',
        'Swaziland': 'SZ',
        'Sweden': 'SE',
        'Switzerland': 'CH',
        'Syrian Arab Republic': 'SY',
        'Taiwan': 'TW',
        'Tajikistan': 'TJ',
        'Tanzania': 'TZ',
        'Thailand': 'TH',
        'Timor-Leste': 'TL',
        'Togo': 'TG',
        'Tokelau': 'TK',
        'Tonga': 'TO',
        'Trinidad And Tobago': 'TT',
        'Tunisia': 'TN',
        'Turkey': 'TR',
        'Turkmenistan': 'TM',
        'Turks And Caicos Islands': 'TC',
        'Tuvalu': 'TV',
        'Uganda': 'UG',
        'Ukraine': 'UA',
        'United Arab Emirates': 'AE',
        'United Kingdom': 'GB',
        'United States': 'US',
        'United States Outlying Islands': 'UM',
        'Uruguay': 'UY',
        'Uzbekistan': 'UZ',
        'Vanuatu': 'VU',
        'Venezuela': 'VE',
        'Vietnam': 'VN',
        'Virgin Islands, British': 'VG',
        'Virgin Islands, U.S.': 'VI',
        'Wallis And Futuna': 'WF',
        'Western Sahara': 'EH',
        'Yemen': 'YE',
        'Zambia': 'ZM',
        'Zimbabwe': 'ZW'
    };
@bilbof

This comment has been minimized.

Show comment
Hide comment
@bilbof

bilbof Jan 4, 2017

ISO 2 to ISO 3

  {
    "AF": "AFG",
    "AX": "ALA",
    "AL": "ALB",
    "DZ": "DZA",
    "AS": "ASM",
    "AD": "AND",
    "AO": "AGO",
    "AI": "AIA",
    "AQ": "ATA",
    "AG": "ATG",
    "AR": "ARG",
    "AM": "ARM",
    "AW": "ABW",
    "AU": "AUS",
    "AT": "AUT",
    "AZ": "AZE",
    "BS": "BHS",
    "BH": "BHR",
    "BD": "BGD",
    "BB": "BRB",
    "BY": "BLR",
    "BE": "BEL",
    "BZ": "BLZ",
    "BJ": "BEN",
    "BM": "BMU",
    "BT": "BTN",
    "BO": "BOL",
    "BQ": "BES",
    "BA": "BIH",
    "BW": "BWA",
    "BV": "BVT",
    "BR": "BRA",
    "IO": "IOT",
    "BN": "BRN",
    "BG": "BGR",
    "BF": "BFA",
    "BI": "BDI",
    "CV": "CPV",
    "KH": "KHM",
    "CM": "CMR",
    "CA": "CAN",
    "KY": "CYM",
    "CF": "CAF",
    "TD": "TCD",
    "CL": "CHL",
    "CN": "CHN",
    "CX": "CXR",
    "CC": "CCK",
    "CO": "COL",
    "KM": "COM",
    "CG": "COG",
    "CD": "COD",
    "CK": "COK",
    "CR": "CRI",
    "CI": "CIV",
    "HR": "HRV",
    "CU": "CUB",
    "CW": "CUW",
    "CY": "CYP",
    "CZ": "CZE",
    "DK": "DNK",
    "DJ": "DJI",
    "DM": "DMA",
    "DO": "DOM",
    "EC": "ECU",
    "EG": "EGY",
    "SV": "SLV",
    "GQ": "GNQ",
    "ER": "ERI",
    "EE": "EST",
    "ET": "ETH",
    "FK": "FLK",
    "FO": "FRO",
    "FJ": "FJI",
    "FI": "FIN",
    "FR": "FRA",
    "GF": "GUF",
    "PF": "PYF",
    "TF": "ATF",
    "GA": "GAB",
    "GM": "GMB",
    "GE": "GEO",
    "DE": "DEU",
    "GH": "GHA",
    "GI": "GIB",
    "GR": "GRC",
    "GL": "GRL",
    "GD": "GRD",
    "GP": "GLP",
    "GU": "GUM",
    "GT": "GTM",
    "GG": "GGY",
    "GN": "GIN",
    "GW": "GNB",
    "GY": "GUY",
    "HT": "HTI",
    "HM": "HMD",
    "VA": "VAT",
    "HN": "HND",
    "HK": "HKG",
    "HU": "HUN",
    "IS": "ISL",
    "IN": "IND",
    "ID": "IDN",
    "IR": "IRN",
    "IQ": "IRQ",
    "IE": "IRL",
    "IM": "IMN",
    "IL": "ISR",
    "IT": "ITA",
    "JM": "JAM",
    "JP": "JPN",
    "JE": "JEY",
    "JO": "JOR",
    "KZ": "KAZ",
    "KE": "KEN",
    "KI": "KIR",
    "KP": "PRK",
    "KR": "KOR",
    "KW": "KWT",
    "KG": "KGZ",
    "LA": "LAO",
    "LV": "LVA",
    "LB": "LBN",
    "LS": "LSO",
    "LR": "LBR",
    "LY": "LBY",
    "LI": "LIE",
    "LT": "LTU",
    "LU": "LUX",
    "MO": "MAC",
    "MK": "MKD",
    "MG": "MDG",
    "MW": "MWI",
    "MY": "MYS",
    "MV": "MDV",
    "ML": "MLI",
    "MT": "MLT",
    "MH": "MHL",
    "MQ": "MTQ",
    "MR": "MRT",
    "MU": "MUS",
    "YT": "MYT",
    "MX": "MEX",
    "FM": "FSM",
    "MD": "MDA",
    "MC": "MCO",
    "MN": "MNG",
    "ME": "MNE",
    "MS": "MSR",
    "MA": "MAR",
    "MZ": "MOZ",
    "MM": "MMR",
    "NA": "NAM",
    "NR": "NRU",
    "NP": "NPL",
    "NL": "NLD",
    "NC": "NCL",
    "NZ": "NZL",
    "NI": "NIC",
    "NE": "NER",
    "NG": "NGA",
    "NU": "NIU",
    "NF": "NFK",
    "MP": "MNP",
    "NO": "NOR",
    "OM": "OMN",
    "PK": "PAK",
    "PW": "PLW",
    "PS": "PSE",
    "PA": "PAN",
    "PG": "PNG",
    "PY": "PRY",
    "PE": "PER",
    "PH": "PHL",
    "PN": "PCN",
    "PL": "POL",
    "PT": "PRT",
    "PR": "PRI",
    "QA": "QAT",
    "RE": "REU",
    "RO": "ROU",
    "RU": "RUS",
    "RW": "RWA",
    "BL": "BLM",
    "SH": "SHN",
    "KN": "KNA",
    "LC": "LCA",
    "MF": "MAF",
    "PM": "SPM",
    "VC": "VCT",
    "WS": "WSM",
    "SM": "SMR",
    "ST": "STP",
    "SA": "SAU",
    "SN": "SEN",
    "RS": "SRB",
    "SC": "SYC",
    "SL": "SLE",
    "SG": "SGP",
    "SX": "SXM",
    "SK": "SVK",
    "SI": "SVN",
    "SB": "SLB",
    "SO": "SOM",
    "ZA": "ZAF",
    "GS": "SGS",
    "SS": "SSD",
    "ES": "ESP",
    "LK": "LKA",
    "SD": "SDN",
    "SR": "SUR",
    "SJ": "SJM",
    "SZ": "SWZ",
    "SE": "SWE",
    "CH": "CHE",
    "SY": "SYR",
    "TW": "TWN",
    "TJ": "TJK",
    "TZ": "TZA",
    "TH": "THA",
    "TL": "TLS",
    "TG": "TGO",
    "TK": "TKL",
    "TO": "TON",
    "TT": "TTO",
    "TN": "TUN",
    "TR": "TUR",
    "TM": "TKM",
    "TC": "TCA",
    "TV": "TUV",
    "UG": "UGA",
    "UA": "UKR",
    "AE": "ARE",
    "GB": "GBR",
    "US": "USA",
    "UM": "UMI",
    "UY": "URY",
    "UZ": "UZB",
    "VU": "VUT",
    "VE": "VEN",
    "VN": "VNM",
    "VG": "VGB",
    "VI": "VIR",
    "WF": "WLF",
    "EH": "ESH",
    "YE": "YEM",
    "ZM": "ZMB",
    "ZW": "ZWE"
  }

ISO 3 to ISO 2

  {
    "iso3": "iso2",
    "AFG": "AF",
    "ALA": "AX",
    "ALB": "AL",
    "DZA": "DZ",
    "ASM": "AS",
    "AND": "AD",
    "AGO": "AO",
    "AIA": "AI",
    "ATA": "AQ",
    "ATG": "AG",
    "ARG": "AR",
    "ARM": "AM",
    "ABW": "AW",
    "AUS": "AU",
    "AUT": "AT",
    "AZE": "AZ",
    "BHS": "BS",
    "BHR": "BH",
    "BGD": "BD",
    "BRB": "BB",
    "BLR": "BY",
    "BEL": "BE",
    "BLZ": "BZ",
    "BEN": "BJ",
    "BMU": "BM",
    "BTN": "BT",
    "BOL": "BO",
    "BES": "BQ",
    "BIH": "BA",
    "BWA": "BW",
    "BVT": "BV",
    "BRA": "BR",
    "IOT": "IO",
    "BRN": "BN",
    "BGR": "BG",
    "BFA": "BF",
    "BDI": "BI",
    "CPV": "CV",
    "KHM": "KH",
    "CMR": "CM",
    "CAN": "CA",
    "CYM": "KY",
    "CAF": "CF",
    "TCD": "TD",
    "CHL": "CL",
    "CHN": "CN",
    "CXR": "CX",
    "CCK": "CC",
    "COL": "CO",
    "COM": "KM",
    "COG": "CG",
    "COD": "CD",
    "COK": "CK",
    "CRI": "CR",
    "CIV": "CI",
    "HRV": "HR",
    "CUB": "CU",
    "CUW": "CW",
    "CYP": "CY",
    "CZE": "CZ",
    "DNK": "DK",
    "DJI": "DJ",
    "DMA": "DM",
    "DOM": "DO",
    "ECU": "EC",
    "EGY": "EG",
    "SLV": "SV",
    "GNQ": "GQ",
    "ERI": "ER",
    "EST": "EE",
    "ETH": "ET",
    "FLK": "FK",
    "FRO": "FO",
    "FJI": "FJ",
    "FIN": "FI",
    "FRA": "FR",
    "GUF": "GF",
    "PYF": "PF",
    "ATF": "TF",
    "GAB": "GA",
    "GMB": "GM",
    "GEO": "GE",
    "DEU": "DE",
    "GHA": "GH",
    "GIB": "GI",
    "GRC": "GR",
    "GRL": "GL",
    "GRD": "GD",
    "GLP": "GP",
    "GUM": "GU",
    "GTM": "GT",
    "GGY": "GG",
    "GIN": "GN",
    "GNB": "GW",
    "GUY": "GY",
    "HTI": "HT",
    "HMD": "HM",
    "VAT": "VA",
    "HND": "HN",
    "HKG": "HK",
    "HUN": "HU",
    "ISL": "IS",
    "IND": "IN",
    "IDN": "ID",
    "IRN": "IR",
    "IRQ": "IQ",
    "IRL": "IE",
    "IMN": "IM",
    "ISR": "IL",
    "ITA": "IT",
    "JAM": "JM",
    "JPN": "JP",
    "JEY": "JE",
    "JOR": "JO",
    "KAZ": "KZ",
    "KEN": "KE",
    "KIR": "KI",
    "PRK": "KP",
    "KOR": "KR",
    "KWT": "KW",
    "KGZ": "KG",
    "LAO": "LA",
    "LVA": "LV",
    "LBN": "LB",
    "LSO": "LS",
    "LBR": "LR",
    "LBY": "LY",
    "LIE": "LI",
    "LTU": "LT",
    "LUX": "LU",
    "MAC": "MO",
    "MKD": "MK",
    "MDG": "MG",
    "MWI": "MW",
    "MYS": "MY",
    "MDV": "MV",
    "MLI": "ML",
    "MLT": "MT",
    "MHL": "MH",
    "MTQ": "MQ",
    "MRT": "MR",
    "MUS": "MU",
    "MYT": "YT",
    "MEX": "MX",
    "FSM": "FM",
    "MDA": "MD",
    "MCO": "MC",
    "MNG": "MN",
    "MNE": "ME",
    "MSR": "MS",
    "MAR": "MA",
    "MOZ": "MZ",
    "MMR": "MM",
    "NAM": "NA",
    "NRU": "NR",
    "NPL": "NP",
    "NLD": "NL",
    "NCL": "NC",
    "NZL": "NZ",
    "NIC": "NI",
    "NER": "NE",
    "NGA": "NG",
    "NIU": "NU",
    "NFK": "NF",
    "MNP": "MP",
    "NOR": "NO",
    "OMN": "OM",
    "PAK": "PK",
    "PLW": "PW",
    "PSE": "PS",
    "PAN": "PA",
    "PNG": "PG",
    "PRY": "PY",
    "PER": "PE",
    "PHL": "PH",
    "PCN": "PN",
    "POL": "PL",
    "PRT": "PT",
    "PRI": "PR",
    "QAT": "QA",
    "REU": "RE",
    "ROU": "RO",
    "RUS": "RU",
    "RWA": "RW",
    "BLM": "BL",
    "SHN": "SH",
    "KNA": "KN",
    "LCA": "LC",
    "MAF": "MF",
    "SPM": "PM",
    "VCT": "VC",
    "WSM": "WS",
    "SMR": "SM",
    "STP": "ST",
    "SAU": "SA",
    "SEN": "SN",
    "SRB": "RS",
    "SYC": "SC",
    "SLE": "SL",
    "SGP": "SG",
    "SXM": "SX",
    "SVK": "SK",
    "SVN": "SI",
    "SLB": "SB",
    "SOM": "SO",
    "ZAF": "ZA",
    "SGS": "GS",
    "SSD": "SS",
    "ESP": "ES",
    "LKA": "LK",
    "SDN": "SD",
    "SUR": "SR",
    "SJM": "SJ",
    "SWZ": "SZ",
    "SWE": "SE",
    "CHE": "CH",
    "SYR": "SY",
    "TWN": "TW",
    "TJK": "TJ",
    "TZA": "TZ",
    "THA": "TH",
    "TLS": "TL",
    "TGO": "TG",
    "TKL": "TK",
    "TON": "TO",
    "TTO": "TT",
    "TUN": "TN",
    "TUR": "TR",
    "TKM": "TM",
    "TCA": "TC",
    "TUV": "TV",
    "UGA": "UG",
    "UKR": "UA",
    "ARE": "AE",
    "GBR": "GB",
    "USA": "US",
    "UMI": "UM",
    "URY": "UY",
    "UZB": "UZ",
    "VUT": "VU",
    "VEN": "VE",
    "VNM": "VN",
    "VGB": "VG",
    "VIR": "VI",
    "WLF": "WF",
    "ESH": "EH",
    "YEM": "YE",
    "ZMB": "ZM",
    "ZWE": "ZW"
  }

bilbof commented Jan 4, 2017

ISO 2 to ISO 3

  {
    "AF": "AFG",
    "AX": "ALA",
    "AL": "ALB",
    "DZ": "DZA",
    "AS": "ASM",
    "AD": "AND",
    "AO": "AGO",
    "AI": "AIA",
    "AQ": "ATA",
    "AG": "ATG",
    "AR": "ARG",
    "AM": "ARM",
    "AW": "ABW",
    "AU": "AUS",
    "AT": "AUT",
    "AZ": "AZE",
    "BS": "BHS",
    "BH": "BHR",
    "BD": "BGD",
    "BB": "BRB",
    "BY": "BLR",
    "BE": "BEL",
    "BZ": "BLZ",
    "BJ": "BEN",
    "BM": "BMU",
    "BT": "BTN",
    "BO": "BOL",
    "BQ": "BES",
    "BA": "BIH",
    "BW": "BWA",
    "BV": "BVT",
    "BR": "BRA",
    "IO": "IOT",
    "BN": "BRN",
    "BG": "BGR",
    "BF": "BFA",
    "BI": "BDI",
    "CV": "CPV",
    "KH": "KHM",
    "CM": "CMR",
    "CA": "CAN",
    "KY": "CYM",
    "CF": "CAF",
    "TD": "TCD",
    "CL": "CHL",
    "CN": "CHN",
    "CX": "CXR",
    "CC": "CCK",
    "CO": "COL",
    "KM": "COM",
    "CG": "COG",
    "CD": "COD",
    "CK": "COK",
    "CR": "CRI",
    "CI": "CIV",
    "HR": "HRV",
    "CU": "CUB",
    "CW": "CUW",
    "CY": "CYP",
    "CZ": "CZE",
    "DK": "DNK",
    "DJ": "DJI",
    "DM": "DMA",
    "DO": "DOM",
    "EC": "ECU",
    "EG": "EGY",
    "SV": "SLV",
    "GQ": "GNQ",
    "ER": "ERI",
    "EE": "EST",
    "ET": "ETH",
    "FK": "FLK",
    "FO": "FRO",
    "FJ": "FJI",
    "FI": "FIN",
    "FR": "FRA",
    "GF": "GUF",
    "PF": "PYF",
    "TF": "ATF",
    "GA": "GAB",
    "GM": "GMB",
    "GE": "GEO",
    "DE": "DEU",
    "GH": "GHA",
    "GI": "GIB",
    "GR": "GRC",
    "GL": "GRL",
    "GD": "GRD",
    "GP": "GLP",
    "GU": "GUM",
    "GT": "GTM",
    "GG": "GGY",
    "GN": "GIN",
    "GW": "GNB",
    "GY": "GUY",
    "HT": "HTI",
    "HM": "HMD",
    "VA": "VAT",
    "HN": "HND",
    "HK": "HKG",
    "HU": "HUN",
    "IS": "ISL",
    "IN": "IND",
    "ID": "IDN",
    "IR": "IRN",
    "IQ": "IRQ",
    "IE": "IRL",
    "IM": "IMN",
    "IL": "ISR",
    "IT": "ITA",
    "JM": "JAM",
    "JP": "JPN",
    "JE": "JEY",
    "JO": "JOR",
    "KZ": "KAZ",
    "KE": "KEN",
    "KI": "KIR",
    "KP": "PRK",
    "KR": "KOR",
    "KW": "KWT",
    "KG": "KGZ",
    "LA": "LAO",
    "LV": "LVA",
    "LB": "LBN",
    "LS": "LSO",
    "LR": "LBR",
    "LY": "LBY",
    "LI": "LIE",
    "LT": "LTU",
    "LU": "LUX",
    "MO": "MAC",
    "MK": "MKD",
    "MG": "MDG",
    "MW": "MWI",
    "MY": "MYS",
    "MV": "MDV",
    "ML": "MLI",
    "MT": "MLT",
    "MH": "MHL",
    "MQ": "MTQ",
    "MR": "MRT",
    "MU": "MUS",
    "YT": "MYT",
    "MX": "MEX",
    "FM": "FSM",
    "MD": "MDA",
    "MC": "MCO",
    "MN": "MNG",
    "ME": "MNE",
    "MS": "MSR",
    "MA": "MAR",
    "MZ": "MOZ",
    "MM": "MMR",
    "NA": "NAM",
    "NR": "NRU",
    "NP": "NPL",
    "NL": "NLD",
    "NC": "NCL",
    "NZ": "NZL",
    "NI": "NIC",
    "NE": "NER",
    "NG": "NGA",
    "NU": "NIU",
    "NF": "NFK",
    "MP": "MNP",
    "NO": "NOR",
    "OM": "OMN",
    "PK": "PAK",
    "PW": "PLW",
    "PS": "PSE",
    "PA": "PAN",
    "PG": "PNG",
    "PY": "PRY",
    "PE": "PER",
    "PH": "PHL",
    "PN": "PCN",
    "PL": "POL",
    "PT": "PRT",
    "PR": "PRI",
    "QA": "QAT",
    "RE": "REU",
    "RO": "ROU",
    "RU": "RUS",
    "RW": "RWA",
    "BL": "BLM",
    "SH": "SHN",
    "KN": "KNA",
    "LC": "LCA",
    "MF": "MAF",
    "PM": "SPM",
    "VC": "VCT",
    "WS": "WSM",
    "SM": "SMR",
    "ST": "STP",
    "SA": "SAU",
    "SN": "SEN",
    "RS": "SRB",
    "SC": "SYC",
    "SL": "SLE",
    "SG": "SGP",
    "SX": "SXM",
    "SK": "SVK",
    "SI": "SVN",
    "SB": "SLB",
    "SO": "SOM",
    "ZA": "ZAF",
    "GS": "SGS",
    "SS": "SSD",
    "ES": "ESP",
    "LK": "LKA",
    "SD": "SDN",
    "SR": "SUR",
    "SJ": "SJM",
    "SZ": "SWZ",
    "SE": "SWE",
    "CH": "CHE",
    "SY": "SYR",
    "TW": "TWN",
    "TJ": "TJK",
    "TZ": "TZA",
    "TH": "THA",
    "TL": "TLS",
    "TG": "TGO",
    "TK": "TKL",
    "TO": "TON",
    "TT": "TTO",
    "TN": "TUN",
    "TR": "TUR",
    "TM": "TKM",
    "TC": "TCA",
    "TV": "TUV",
    "UG": "UGA",
    "UA": "UKR",
    "AE": "ARE",
    "GB": "GBR",
    "US": "USA",
    "UM": "UMI",
    "UY": "URY",
    "UZ": "UZB",
    "VU": "VUT",
    "VE": "VEN",
    "VN": "VNM",
    "VG": "VGB",
    "VI": "VIR",
    "WF": "WLF",
    "EH": "ESH",
    "YE": "YEM",
    "ZM": "ZMB",
    "ZW": "ZWE"
  }

ISO 3 to ISO 2

  {
    "iso3": "iso2",
    "AFG": "AF",
    "ALA": "AX",
    "ALB": "AL",
    "DZA": "DZ",
    "ASM": "AS",
    "AND": "AD",
    "AGO": "AO",
    "AIA": "AI",
    "ATA": "AQ",
    "ATG": "AG",
    "ARG": "AR",
    "ARM": "AM",
    "ABW": "AW",
    "AUS": "AU",
    "AUT": "AT",
    "AZE": "AZ",
    "BHS": "BS",
    "BHR": "BH",
    "BGD": "BD",
    "BRB": "BB",
    "BLR": "BY",
    "BEL": "BE",
    "BLZ": "BZ",
    "BEN": "BJ",
    "BMU": "BM",
    "BTN": "BT",
    "BOL": "BO",
    "BES": "BQ",
    "BIH": "BA",
    "BWA": "BW",
    "BVT": "BV",
    "BRA": "BR",
    "IOT": "IO",
    "BRN": "BN",
    "BGR": "BG",
    "BFA": "BF",
    "BDI": "BI",
    "CPV": "CV",
    "KHM": "KH",
    "CMR": "CM",
    "CAN": "CA",
    "CYM": "KY",
    "CAF": "CF",
    "TCD": "TD",
    "CHL": "CL",
    "CHN": "CN",
    "CXR": "CX",
    "CCK": "CC",
    "COL": "CO",
    "COM": "KM",
    "COG": "CG",
    "COD": "CD",
    "COK": "CK",
    "CRI": "CR",
    "CIV": "CI",
    "HRV": "HR",
    "CUB": "CU",
    "CUW": "CW",
    "CYP": "CY",
    "CZE": "CZ",
    "DNK": "DK",
    "DJI": "DJ",
    "DMA": "DM",
    "DOM": "DO",
    "ECU": "EC",
    "EGY": "EG",
    "SLV": "SV",
    "GNQ": "GQ",
    "ERI": "ER",
    "EST": "EE",
    "ETH": "ET",
    "FLK": "FK",
    "FRO": "FO",
    "FJI": "FJ",
    "FIN": "FI",
    "FRA": "FR",
    "GUF": "GF",
    "PYF": "PF",
    "ATF": "TF",
    "GAB": "GA",
    "GMB": "GM",
    "GEO": "GE",
    "DEU": "DE",
    "GHA": "GH",
    "GIB": "GI",
    "GRC": "GR",
    "GRL": "GL",
    "GRD": "GD",
    "GLP": "GP",
    "GUM": "GU",
    "GTM": "GT",
    "GGY": "GG",
    "GIN": "GN",
    "GNB": "GW",
    "GUY": "GY",
    "HTI": "HT",
    "HMD": "HM",
    "VAT": "VA",
    "HND": "HN",
    "HKG": "HK",
    "HUN": "HU",
    "ISL": "IS",
    "IND": "IN",
    "IDN": "ID",
    "IRN": "IR",
    "IRQ": "IQ",
    "IRL": "IE",
    "IMN": "IM",
    "ISR": "IL",
    "ITA": "IT",
    "JAM": "JM",
    "JPN": "JP",
    "JEY": "JE",
    "JOR": "JO",
    "KAZ": "KZ",
    "KEN": "KE",
    "KIR": "KI",
    "PRK": "KP",
    "KOR": "KR",
    "KWT": "KW",
    "KGZ": "KG",
    "LAO": "LA",
    "LVA": "LV",
    "LBN": "LB",
    "LSO": "LS",
    "LBR": "LR",
    "LBY": "LY",
    "LIE": "LI",
    "LTU": "LT",
    "LUX": "LU",
    "MAC": "MO",
    "MKD": "MK",
    "MDG": "MG",
    "MWI": "MW",
    "MYS": "MY",
    "MDV": "MV",
    "MLI": "ML",
    "MLT": "MT",
    "MHL": "MH",
    "MTQ": "MQ",
    "MRT": "MR",
    "MUS": "MU",
    "MYT": "YT",
    "MEX": "MX",
    "FSM": "FM",
    "MDA": "MD",
    "MCO": "MC",
    "MNG": "MN",
    "MNE": "ME",
    "MSR": "MS",
    "MAR": "MA",
    "MOZ": "MZ",
    "MMR": "MM",
    "NAM": "NA",
    "NRU": "NR",
    "NPL": "NP",
    "NLD": "NL",
    "NCL": "NC",
    "NZL": "NZ",
    "NIC": "NI",
    "NER": "NE",
    "NGA": "NG",
    "NIU": "NU",
    "NFK": "NF",
    "MNP": "MP",
    "NOR": "NO",
    "OMN": "OM",
    "PAK": "PK",
    "PLW": "PW",
    "PSE": "PS",
    "PAN": "PA",
    "PNG": "PG",
    "PRY": "PY",
    "PER": "PE",
    "PHL": "PH",
    "PCN": "PN",
    "POL": "PL",
    "PRT": "PT",
    "PRI": "PR",
    "QAT": "QA",
    "REU": "RE",
    "ROU": "RO",
    "RUS": "RU",
    "RWA": "RW",
    "BLM": "BL",
    "SHN": "SH",
    "KNA": "KN",
    "LCA": "LC",
    "MAF": "MF",
    "SPM": "PM",
    "VCT": "VC",
    "WSM": "WS",
    "SMR": "SM",
    "STP": "ST",
    "SAU": "SA",
    "SEN": "SN",
    "SRB": "RS",
    "SYC": "SC",
    "SLE": "SL",
    "SGP": "SG",
    "SXM": "SX",
    "SVK": "SK",
    "SVN": "SI",
    "SLB": "SB",
    "SOM": "SO",
    "ZAF": "ZA",
    "SGS": "GS",
    "SSD": "SS",
    "ESP": "ES",
    "LKA": "LK",
    "SDN": "SD",
    "SUR": "SR",
    "SJM": "SJ",
    "SWZ": "SZ",
    "SWE": "SE",
    "CHE": "CH",
    "SYR": "SY",
    "TWN": "TW",
    "TJK": "TJ",
    "TZA": "TZ",
    "THA": "TH",
    "TLS": "TL",
    "TGO": "TG",
    "TKL": "TK",
    "TON": "TO",
    "TTO": "TT",
    "TUN": "TN",
    "TUR": "TR",
    "TKM": "TM",
    "TCA": "TC",
    "TUV": "TV",
    "UGA": "UG",
    "UKR": "UA",
    "ARE": "AE",
    "GBR": "GB",
    "USA": "US",
    "UMI": "UM",
    "URY": "UY",
    "UZB": "UZ",
    "VUT": "VU",
    "VEN": "VE",
    "VNM": "VN",
    "VGB": "VG",
    "VIR": "VI",
    "WLF": "WF",
    "ESH": "EH",
    "YEM": "YE",
    "ZMB": "ZM",
    "ZWE": "ZW"
  }
@mrhieu

This comment has been minimized.

Show comment
Hide comment
@mrhieu

mrhieu Jan 22, 2017

Lower case for ccode (and escaped string)

[
  {
    "code": "af",
    "name": "Afghanistan"
  },
  {
    "code": "ax",
    "name": "Aland Islands"
  },
  {
    "code": "al",
    "name": "Albania"
  },
  {
    "code": "dz",
    "name": "Algeria"
  },
  {
    "code": "as",
    "name": "American Samoa"
  },
  {
    "code": "ad",
    "name": "Andorra"
  },
  {
    "code": "ao",
    "name": "Angola"
  },
  {
    "code": "ai",
    "name": "Anguilla"
  },
  {
    "code": "aq",
    "name": "Antarctica"
  },
  {
    "code": "ag",
    "name": "Antigua And Barbuda"
  },
  {
    "code": "ar",
    "name": "Argentina"
  },
  {
    "code": "am",
    "name": "Armenia"
  },
  {
    "code": "aw",
    "name": "Aruba"
  },
  {
    "code": "au",
    "name": "Australia"
  },
  {
    "code": "at",
    "name": "Austria"
  },
  {
    "code": "az",
    "name": "Azerbaijan"
  },
  {
    "code": "bs",
    "name": "Bahamas"
  },
  {
    "code": "bh",
    "name": "Bahrain"
  },
  {
    "code": "bd",
    "name": "Bangladesh"
  },
  {
    "code": "bb",
    "name": "Barbados"
  },
  {
    "code": "by",
    "name": "Belarus"
  },
  {
    "code": "be",
    "name": "Belgium"
  },
  {
    "code": "bz",
    "name": "Belize"
  },
  {
    "code": "bj",
    "name": "Benin"
  },
  {
    "code": "bm",
    "name": "Bermuda"
  },
  {
    "code": "bt",
    "name": "Bhutan"
  },
  {
    "code": "bo",
    "name": "Bolivia"
  },
  {
    "code": "ba",
    "name": "Bosnia And Herzegovina"
  },
  {
    "code": "bw",
    "name": "Botswana"
  },
  {
    "code": "bv",
    "name": "Bouvet Island"
  },
  {
    "code": "br",
    "name": "Brazil"
  },
  {
    "code": "io",
    "name": "British Indian Ocean Territory"
  },
  {
    "code": "bn",
    "name": "Brunei Darussalam"
  },
  {
    "code": "bg",
    "name": "Bulgaria"
  },
  {
    "code": "bf",
    "name": "Burkina Faso"
  },
  {
    "code": "bi",
    "name": "Burundi"
  },
  {
    "code": "kh",
    "name": "Cambodia"
  },
  {
    "code": "cm",
    "name": "Cameroon"
  },
  {
    "code": "ca",
    "name": "Canada"
  },
  {
    "code": "cv",
    "name": "Cape Verde"
  },
  {
    "code": "ky",
    "name": "Cayman Islands"
  },
  {
    "code": "cf",
    "name": "Central African Republic"
  },
  {
    "code": "td",
    "name": "Chad"
  },
  {
    "code": "cl",
    "name": "Chile"
  },
  {
    "code": "cn",
    "name": "China"
  },
  {
    "code": "cx",
    "name": "Christmas Island"
  },
  {
    "code": "cc",
    "name": "Cocos (Keeling) Islands"
  },
  {
    "code": "co",
    "name": "Colombia"
  },
  {
    "code": "km",
    "name": "Comoros"
  },
  {
    "code": "cg",
    "name": "Congo"
  },
  {
    "code": "cd",
    "name": "Congo, Democratic Republic"
  },
  {
    "code": "ck",
    "name": "Cook Islands"
  },
  {
    "code": "cr",
    "name": "Costa Rica"
  },
  {
    "code": "ci",
    "name": "Cote D'Ivoire"
  },
  {
    "code": "hr",
    "name": "Croatia"
  },
  {
    "code": "cu",
    "name": "Cuba"
  },
  {
    "code": "cy",
    "name": "Cyprus"
  },
  {
    "code": "cz",
    "name": "Czech Republic"
  },
  {
    "code": "dk",
    "name": "Denmark"
  },
  {
    "code": "dj",
    "name": "Djibouti"
  },
  {
    "code": "dm",
    "name": "Dominica"
  },
  {
    "code": "do",
    "name": "Dominican Republic"
  },
  {
    "code": "ec",
    "name": "Ecuador"
  },
  {
    "code": "eg",
    "name": "Egypt"
  },
  {
    "code": "sv",
    "name": "El Salvador"
  },
  {
    "code": "gq",
    "name": "Equatorial Guinea"
  },
  {
    "code": "er",
    "name": "Eritrea"
  },
  {
    "code": "ee",
    "name": "Estonia"
  },
  {
    "code": "et",
    "name": "Ethiopia"
  },
  {
    "code": "fk",
    "name": "Falkland Islands (Malvinas)"
  },
  {
    "code": "fo",
    "name": "Faroe Islands"
  },
  {
    "code": "fj",
    "name": "Fiji"
  },
  {
    "code": "fi",
    "name": "Finland"
  },
  {
    "code": "fr",
    "name": "France"
  },
  {
    "code": "gf",
    "name": "French Guiana"
  },
  {
    "code": "pf",
    "name": "French Polynesia"
  },
  {
    "code": "tf",
    "name": "French Southern Territories"
  },
  {
    "code": "ga",
    "name": "Gabon"
  },
  {
    "code": "gm",
    "name": "Gambia"
  },
  {
    "code": "ge",
    "name": "Georgia"
  },
  {
    "code": "de",
    "name": "Germany"
  },
  {
    "code": "gh",
    "name": "Ghana"
  },
  {
    "code": "gi",
    "name": "Gibraltar"
  },
  {
    "code": "gr",
    "name": "Greece"
  },
  {
    "code": "gl",
    "name": "Greenland"
  },
  {
    "code": "gd",
    "name": "Grenada"
  },
  {
    "code": "gp",
    "name": "Guadeloupe"
  },
  {
    "code": "gu",
    "name": "Guam"
  },
  {
    "code": "gt",
    "name": "Guatemala"
  },
  {
    "code": "gg",
    "name": "Guernsey"
  },
  {
    "code": "gn",
    "name": "Guinea"
  },
  {
    "code": "gw",
    "name": "Guinea-Bissau"
  },
  {
    "code": "gy",
    "name": "Guyana"
  },
  {
    "code": "ht",
    "name": "Haiti"
  },
  {
    "code": "hm",
    "name": "Heard Island & Mcdonald Islands"
  },
  {
    "code": "va",
    "name": "Holy See (Vatican City State)"
  },
  {
    "code": "hn",
    "name": "Honduras"
  },
  {
    "code": "hk",
    "name": "Hong Kong"
  },
  {
    "code": "hu",
    "name": "Hungary"
  },
  {
    "code": "is",
    "name": "Iceland"
  },
  {
    "code": "in",
    "name": "India"
  },
  {
    "code": "id",
    "name": "Indonesia"
  },
  {
    "code": "ir",
    "name": "Iran, Islamic Republic Of"
  },
  {
    "code": "iq",
    "name": "Iraq"
  },
  {
    "code": "ie",
    "name": "Ireland"
  },
  {
    "code": "im",
    "name": "Isle Of Man"
  },
  {
    "code": "il",
    "name": "Israel"
  },
  {
    "code": "it",
    "name": "Italy"
  },
  {
    "code": "jm",
    "name": "Jamaica"
  },
  {
    "code": "jp",
    "name": "Japan"
  },
  {
    "code": "je",
    "name": "Jersey"
  },
  {
    "code": "jo",
    "name": "Jordan"
  },
  {
    "code": "kz",
    "name": "Kazakhstan"
  },
  {
    "code": "ke",
    "name": "Kenya"
  },
  {
    "code": "ki",
    "name": "Kiribati"
  },
  {
    "code": "kr",
    "name": "Korea"
  },
  {
    "code": "kw",
    "name": "Kuwait"
  },
  {
    "code": "kg",
    "name": "Kyrgyzstan"
  },
  {
    "code": "la",
    "name": "Lao People's Democratic Republic"
  },
  {
    "code": "lv",
    "name": "Latvia"
  },
  {
    "code": "lb",
    "name": "Lebanon"
  },
  {
    "code": "ls",
    "name": "Lesotho"
  },
  {
    "code": "lr",
    "name": "Liberia"
  },
  {
    "code": "ly",
    "name": "Libyan Arab Jamahiriya"
  },
  {
    "code": "li",
    "name": "Liechtenstein"
  },
  {
    "code": "lt",
    "name": "Lithuania"
  },
  {
    "code": "lu",
    "name": "Luxembourg"
  },
  {
    "code": "mo",
    "name": "Macao"
  },
  {
    "code": "mk",
    "name": "Macedonia"
  },
  {
    "code": "mg",
    "name": "Madagascar"
  },
  {
    "code": "mw",
    "name": "Malawi"
  },
  {
    "code": "my",
    "name": "Malaysia"
  },
  {
    "code": "mv",
    "name": "Maldives"
  },
  {
    "code": "ml",
    "name": "Mali"
  },
  {
    "code": "mt",
    "name": "Malta"
  },
  {
    "code": "mh",
    "name": "Marshall Islands"
  },
  {
    "code": "mq",
    "name": "Martinique"
  },
  {
    "code": "mr",
    "name": "Mauritania"
  },
  {
    "code": "mu",
    "name": "Mauritius"
  },
  {
    "code": "yt",
    "name": "Mayotte"
  },
  {
    "code": "mx",
    "name": "Mexico"
  },
  {
    "code": "fm",
    "name": "Micronesia, Federated States Of"
  },
  {
    "code": "md",
    "name": "Moldova"
  },
  {
    "code": "mc",
    "name": "Monaco"
  },
  {
    "code": "mn",
    "name": "Mongolia"
  },
  {
    "code": "me",
    "name": "Montenegro"
  },
  {
    "code": "ms",
    "name": "Montserrat"
  },
  {
    "code": "ma",
    "name": "Morocco"
  },
  {
    "code": "mz",
    "name": "Mozambique"
  },
  {
    "code": "mm",
    "name": "Myanmar"
  },
  {
    "code": "na",
    "name": "Namibia"
  },
  {
    "code": "nr",
    "name": "Nauru"
  },
  {
    "code": "np",
    "name": "Nepal"
  },
  {
    "code": "nl",
    "name": "Netherlands"
  },
  {
    "code": "an",
    "name": "Netherlands Antilles"
  },
  {
    "code": "nc",
    "name": "New Caledonia"
  },
  {
    "code": "nz",
    "name": "New Zealand"
  },
  {
    "code": "ni",
    "name": "Nicaragua"
  },
  {
    "code": "ne",
    "name": "Niger"
  },
  {
    "code": "ng",
    "name": "Nigeria"
  },
  {
    "code": "nu",
    "name": "Niue"
  },
  {
    "code": "nf",
    "name": "Norfolk Island"
  },
  {
    "code": "mp",
    "name": "Northern Mariana Islands"
  },
  {
    "code": "no",
    "name": "Norway"
  },
  {
    "code": "om",
    "name": "Oman"
  },
  {
    "code": "pk",
    "name": "Pakistan"
  },
  {
    "code": "pw",
    "name": "Palau"
  },
  {
    "code": "ps",
    "name": "Palestinian Territory, Occupied"
  },
  {
    "code": "pa",
    "name": "Panama"
  },
  {
    "code": "pg",
    "name": "Papua New Guinea"
  },
  {
    "code": "py",
    "name": "Paraguay"
  },
  {
    "code": "pe",
    "name": "Peru"
  },
  {
    "code": "ph",
    "name": "Philippines"
  },
  {
    "code": "pn",
    "name": "Pitcairn"
  },
  {
    "code": "pl",
    "name": "Poland"
  },
  {
    "code": "pt",
    "name": "Portugal"
  },
  {
    "code": "pr",
    "name": "Puerto Rico"
  },
  {
    "code": "qa",
    "name": "Qatar"
  },
  {
    "code": "re",
    "name": "Reunion"
  },
  {
    "code": "ro",
    "name": "Romania"
  },
  {
    "code": "ru",
    "name": "Russian Federation"
  },
  {
    "code": "rw",
    "name": "Rwanda"
  },
  {
    "code": "bl",
    "name": "Saint Barthelemy"
  },
  {
    "code": "sh",
    "name": "Saint Helena"
  },
  {
    "code": "kn",
    "name": "Saint Kitts And Nevis"
  },
  {
    "code": "lc",
    "name": "Saint Lucia"
  },
  {
    "code": "mf",
    "name": "Saint Martin"
  },
  {
    "code": "pm",
    "name": "Saint Pierre And Miquelon"
  },
  {
    "code": "vc",
    "name": "Saint Vincent And Grenadines"
  },
  {
    "code": "ws",
    "name": "Samoa"
  },
  {
    "code": "sm",
    "name": "San Marino"
  },
  {
    "code": "st",
    "name": "Sao Tome And Principe"
  },
  {
    "code": "sa",
    "name": "Saudi Arabia"
  },
  {
    "code": "sn",
    "name": "Senegal"
  },
  {
    "code": "rs",
    "name": "Serbia"
  },
  {
    "code": "sc",
    "name": "Seychelles"
  },
  {
    "code": "sl",
    "name": "Sierra Leone"
  },
  {
    "code": "sg",
    "name": "Singapore"
  },
  {
    "code": "sk",
    "name": "Slovakia"
  },
  {
    "code": "si",
    "name": "Slovenia"
  },
  {
    "code": "sb",
    "name": "Solomon Islands"
  },
  {
    "code": "so",
    "name": "Somalia"
  },
  {
    "code": "za",
    "name": "South Africa"
  },
  {
    "code": "gs",
    "name": "South Georgia And Sandwich Isl."
  },
  {
    "code": "es",
    "name": "Spain"
  },
  {
    "code": "lk",
    "name": "Sri Lanka"
  },
  {
    "code": "sd",
    "name": "Sudan"
  },
  {
    "code": "sr",
    "name": "Suriname"
  },
  {
    "code": "sj",
    "name": "Svalbard And Jan Mayen"
  },
  {
    "code": "sz",
    "name": "Swaziland"
  },
  {
    "code": "se",
    "name": "Sweden"
  },
  {
    "code": "ch",
    "name": "Switzerland"
  },
  {
    "code": "sy",
    "name": "Syrian Arab Republic"
  },
  {
    "code": "tw",
    "name": "Taiwan"
  },
  {
    "code": "tj",
    "name": "Tajikistan"
  },
  {
    "code": "tz",
    "name": "Tanzania"
  },
  {
    "code": "th",
    "name": "Thailand"
  },
  {
    "code": "tl",
    "name": "Timor-Leste"
  },
  {
    "code": "tg",
    "name": "Togo"
  },
  {
    "code": "tk",
    "name": "Tokelau"
  },
  {
    "code": "to",
    "name": "Tonga"
  },
  {
    "code": "tt",
    "name": "Trinidad And Tobago"
  },
  {
    "code": "tn",
    "name": "Tunisia"
  },
  {
    "code": "tr",
    "name": "Turkey"
  },
  {
    "code": "tm",
    "name": "Turkmenistan"
  },
  {
    "code": "tc",
    "name": "Turks And Caicos Islands"
  },
  {
    "code": "tv",
    "name": "Tuvalu"
  },
  {
    "code": "ug",
    "name": "Uganda"
  },
  {
    "code": "ua",
    "name": "Ukraine"
  },
  {
    "code": "ae",
    "name": "United Arab Emirates"
  },
  {
    "code": "gb",
    "name": "United Kingdom"
  },
  {
    "code": "us",
    "name": "United States"
  },
  {
    "code": "um",
    "name": "United States Outlying Islands"
  },
  {
    "code": "uy",
    "name": "Uruguay"
  },
  {
    "code": "uz",
    "name": "Uzbekistan"
  },
  {
    "code": "vu",
    "name": "Vanuatu"
  },
  {
    "code": "ve",
    "name": "Venezuela"
  },
  {
    "code": "vn",
    "name": "Viet Nam"
  },
  {
    "code": "vg",
    "name": "Virgin Islands, British"
  },
  {
    "code": "vi",
    "name": "Virgin Islands, U.S."
  },
  {
    "code": "wf",
    "name": "Wallis And Futuna"
  },
  {
    "code": "eh",
    "name": "Western Sahara"
  },
  {
    "code": "ye",
    "name": "Yemen"
  },
  {
    "code": "zm",
    "name": "Zambia"
  },
  {
    "code": "zw",
    "name": "Zimbabwe"
  }
]

mrhieu commented Jan 22, 2017

Lower case for ccode (and escaped string)

[
  {
    "code": "af",
    "name": "Afghanistan"
  },
  {
    "code": "ax",
    "name": "Aland Islands"
  },
  {
    "code": "al",
    "name": "Albania"
  },
  {
    "code": "dz",
    "name": "Algeria"
  },
  {
    "code": "as",
    "name": "American Samoa"
  },
  {
    "code": "ad",
    "name": "Andorra"
  },
  {
    "code": "ao",
    "name": "Angola"
  },
  {
    "code": "ai",
    "name": "Anguilla"
  },
  {
    "code": "aq",
    "name": "Antarctica"
  },
  {
    "code": "ag",
    "name": "Antigua And Barbuda"
  },
  {
    "code": "ar",
    "name": "Argentina"
  },
  {
    "code": "am",
    "name": "Armenia"
  },
  {
    "code": "aw",
    "name": "Aruba"
  },
  {
    "code": "au",
    "name": "Australia"
  },
  {
    "code": "at",
    "name": "Austria"
  },
  {
    "code": "az",
    "name": "Azerbaijan"
  },
  {
    "code": "bs",
    "name": "Bahamas"
  },
  {
    "code": "bh",
    "name": "Bahrain"
  },
  {
    "code": "bd",
    "name": "Bangladesh"
  },
  {
    "code": "bb",
    "name": "Barbados"
  },
  {
    "code": "by",
    "name": "Belarus"
  },
  {
    "code": "be",
    "name": "Belgium"
  },
  {
    "code": "bz",
    "name": "Belize"
  },
  {
    "code": "bj",
    "name": "Benin"
  },
  {
    "code": "bm",
    "name": "Bermuda"
  },
  {
    "code": "bt",
    "name": "Bhutan"
  },
  {
    "code": "bo",
    "name": "Bolivia"
  },
  {
    "code": "ba",
    "name": "Bosnia And Herzegovina"
  },
  {
    "code": "bw",
    "name": "Botswana"
  },
  {
    "code": "bv",
    "name": "Bouvet Island"
  },
  {
    "code": "br",
    "name": "Brazil"
  },
  {
    "code": "io",
    "name": "British Indian Ocean Territory"
  },
  {
    "code": "bn",
    "name": "Brunei Darussalam"
  },
  {
    "code": "bg",
    "name": "Bulgaria"
  },
  {
    "code": "bf",
    "name": "Burkina Faso"
  },
  {
    "code": "bi",
    "name": "Burundi"
  },
  {
    "code": "kh",
    "name": "Cambodia"
  },
  {
    "code": "cm",
    "name": "Cameroon"
  },
  {
    "code": "ca",
    "name": "Canada"
  },
  {
    "code": "cv",
    "name": "Cape Verde"
  },
  {
    "code": "ky",
    "name": "Cayman Islands"
  },
  {
    "code": "cf",
    "name": "Central African Republic"
  },
  {
    "code": "td",
    "name": "Chad"
  },
  {
    "code": "cl",
    "name": "Chile"
  },
  {
    "code": "cn",
    "name": "China"
  },
  {
    "code": "cx",
    "name": "Christmas Island"
  },
  {
    "code": "cc",
    "name": "Cocos (Keeling) Islands"
  },
  {
    "code": "co",
    "name": "Colombia"
  },
  {
    "code": "km",
    "name": "Comoros"
  },
  {
    "code": "cg",
    "name": "Congo"
  },
  {
    "code": "cd",
    "name": "Congo, Democratic Republic"
  },
  {
    "code": "ck",
    "name": "Cook Islands"
  },
  {
    "code": "cr",
    "name": "Costa Rica"
  },
  {
    "code": "ci",
    "name": "Cote D'Ivoire"
  },
  {
    "code": "hr",
    "name": "Croatia"
  },
  {
    "code": "cu",
    "name": "Cuba"
  },
  {
    "code": "cy",
    "name": "Cyprus"
  },
  {
    "code": "cz",
    "name": "Czech Republic"
  },
  {
    "code": "dk",
    "name": "Denmark"
  },
  {
    "code": "dj",
    "name": "Djibouti"
  },
  {
    "code": "dm",
    "name": "Dominica"
  },
  {
    "code": "do",
    "name": "Dominican Republic"
  },
  {
    "code": "ec",
    "name": "Ecuador"
  },
  {
    "code": "eg",
    "name": "Egypt"
  },
  {
    "code": "sv",
    "name": "El Salvador"
  },
  {
    "code": "gq",
    "name": "Equatorial Guinea"
  },
  {
    "code": "er",
    "name": "Eritrea"
  },
  {
    "code": "ee",
    "name": "Estonia"
  },
  {
    "code": "et",
    "name": "Ethiopia"
  },
  {
    "code": "fk",
    "name": "Falkland Islands (Malvinas)"
  },
  {
    "code": "fo",
    "name": "Faroe Islands"
  },
  {
    "code": "fj",
    "name": "Fiji"
  },
  {
    "code": "fi",
    "name": "Finland"
  },
  {
    "code": "fr",
    "name": "France"
  },
  {
    "code": "gf",
    "name": "French Guiana"
  },
  {
    "code": "pf",
    "name": "French Polynesia"
  },
  {
    "code": "tf",
    "name": "French Southern Territories"
  },
  {
    "code": "ga",
    "name": "Gabon"
  },
  {
    "code": "gm",
    "name": "Gambia"
  },
  {
    "code": "ge",
    "name": "Georgia"
  },
  {
    "code": "de",
    "name": "Germany"
  },
  {
    "code": "gh",
    "name": "Ghana"
  },
  {
    "code": "gi",
    "name": "Gibraltar"
  },
  {
    "code": "gr",
    "name": "Greece"
  },
  {
    "code": "gl",
    "name": "Greenland"
  },
  {
    "code": "gd",
    "name": "Grenada"
  },
  {
    "code": "gp",
    "name": "Guadeloupe"
  },
  {
    "code": "gu",
    "name": "Guam"
  },
  {
    "code": "gt",
    "name": "Guatemala"
  },
  {
    "code": "gg",
    "name": "Guernsey"
  },
  {
    "code": "gn",
    "name": "Guinea"
  },
  {
    "code": "gw",
    "name": "Guinea-Bissau"
  },
  {
    "code": "gy",
    "name": "Guyana"
  },
  {
    "code": "ht",
    "name": "Haiti"
  },
  {
    "code": "hm",
    "name": "Heard Island & Mcdonald Islands"
  },
  {
    "code": "va",
    "name": "Holy See (Vatican City State)"
  },
  {
    "code": "hn",
    "name": "Honduras"
  },
  {
    "code": "hk",
    "name": "Hong Kong"
  },
  {
    "code": "hu",
    "name": "Hungary"
  },
  {
    "code": "is",
    "name": "Iceland"
  },
  {
    "code": "in",
    "name": "India"
  },
  {
    "code": "id",
    "name": "Indonesia"
  },
  {
    "code": "ir",
    "name": "Iran, Islamic Republic Of"
  },
  {
    "code": "iq",
    "name": "Iraq"
  },
  {
    "code": "ie",
    "name": "Ireland"
  },
  {
    "code": "im",
    "name": "Isle Of Man"
  },
  {
    "code": "il",
    "name": "Israel"
  },
  {
    "code": "it",
    "name": "Italy"
  },
  {
    "code": "jm",
    "name": "Jamaica"
  },
  {
    "code": "jp",
    "name": "Japan"
  },
  {
    "code": "je",
    "name": "Jersey"
  },
  {
    "code": "jo",
    "name": "Jordan"
  },
  {
    "code": "kz",
    "name": "Kazakhstan"
  },
  {
    "code": "ke",
    "name": "Kenya"
  },
  {
    "code": "ki",
    "name": "Kiribati"
  },
  {
    "code": "kr",
    "name": "Korea"
  },
  {
    "code": "kw",
    "name": "Kuwait"
  },
  {
    "code": "kg",
    "name": "Kyrgyzstan"
  },
  {
    "code": "la",
    "name": "Lao People's Democratic Republic"
  },
  {
    "code": "lv",
    "name": "Latvia"
  },
  {
    "code": "lb",
    "name": "Lebanon"
  },
  {
    "code": "ls",
    "name": "Lesotho"
  },
  {
    "code": "lr",
    "name": "Liberia"
  },
  {
    "code": "ly",
    "name": "Libyan Arab Jamahiriya"
  },
  {
    "code": "li",
    "name": "Liechtenstein"
  },
  {
    "code": "lt",
    "name": "Lithuania"
  },
  {
    "code": "lu",
    "name": "Luxembourg"
  },
  {
    "code": "mo",
    "name": "Macao"
  },
  {
    "code": "mk",
    "name": "Macedonia"
  },
  {
    "code": "mg",
    "name": "Madagascar"
  },
  {
    "code": "mw",
    "name": "Malawi"
  },
  {
    "code": "my",
    "name": "Malaysia"
  },
  {
    "code": "mv",
    "name": "Maldives"
  },
  {
    "code": "ml",
    "name": "Mali"
  },
  {
    "code": "mt",
    "name": "Malta"
  },
  {
    "code": "mh",
    "name": "Marshall Islands"
  },
  {
    "code": "mq",
    "name": "Martinique"
  },
  {
    "code": "mr",
    "name": "Mauritania"
  },
  {
    "code": "mu",
    "name": "Mauritius"
  },
  {
    "code": "yt",
    "name": "Mayotte"
  },
  {
    "code": "mx",
    "name": "Mexico"
  },
  {
    "code": "fm",
    "name": "Micronesia, Federated States Of"
  },
  {
    "code": "md",
    "name": "Moldova"
  },
  {
    "code": "mc",
    "name": "Monaco"
  },
  {
    "code": "mn",
    "name": "Mongolia"
  },
  {
    "code": "me",
    "name": "Montenegro"
  },
  {
    "code": "ms",
    "name": "Montserrat"
  },
  {
    "code": "ma",
    "name": "Morocco"
  },
  {
    "code": "mz",
    "name": "Mozambique"
  },
  {
    "code": "mm",
    "name": "Myanmar"
  },
  {
    "code": "na",
    "name": "Namibia"
  },
  {
    "code": "nr",
    "name": "Nauru"
  },
  {
    "code": "np",
    "name": "Nepal"
  },
  {
    "code": "nl",
    "name": "Netherlands"
  },
  {
    "code": "an",
    "name": "Netherlands Antilles"
  },
  {
    "code": "nc",
    "name": "New Caledonia"
  },
  {
    "code": "nz",
    "name": "New Zealand"
  },
  {
    "code": "ni",
    "name": "Nicaragua"
  },
  {
    "code": "ne",
    "name": "Niger"
  },
  {
    "code": "ng",
    "name": "Nigeria"
  },
  {
    "code": "nu",
    "name": "Niue"
  },
  {
    "code": "nf",
    "name": "Norfolk Island"
  },
  {
    "code": "mp",
    "name": "Northern Mariana Islands"
  },
  {
    "code": "no",
    "name": "Norway"
  },
  {
    "code": "om",
    "name": "Oman"
  },
  {
    "code": "pk",
    "name": "Pakistan"
  },
  {
    "code": "pw",
    "name": "Palau"
  },
  {
    "code": "ps",
    "name": "Palestinian Territory, Occupied"
  },
  {
    "code": "pa",
    "name": "Panama"
  },
  {
    "code": "pg",
    "name": "Papua New Guinea"
  },
  {
    "code": "py",
    "name": "Paraguay"
  },
  {
    "code": "pe",
    "name": "Peru"
  },
  {
    "code": "ph",
    "name": "Philippines"
  },
  {
    "code": "pn",
    "name": "Pitcairn"
  },
  {
    "code": "pl",
    "name": "Poland"
  },
  {
    "code": "pt",
    "name": "Portugal"
  },
  {
    "code": "pr",
    "name": "Puerto Rico"
  },
  {
    "code": "qa",
    "name": "Qatar"
  },
  {
    "code": "re",
    "name": "Reunion"
  },
  {
    "code": "ro",
    "name": "Romania"
  },
  {
    "code": "ru",
    "name": "Russian Federation"
  },
  {
    "code": "rw",
    "name": "Rwanda"
  },
  {
    "code": "bl",
    "name": "Saint Barthelemy"
  },
  {
    "code": "sh",
    "name": "Saint Helena"
  },
  {
    "code": "kn",
    "name": "Saint Kitts And Nevis"
  },
  {
    "code": "lc",
    "name": "Saint Lucia"
  },
  {
    "code": "mf",
    "name": "Saint Martin"
  },
  {
    "code": "pm",
    "name": "Saint Pierre And Miquelon"
  },
  {
    "code": "vc",
    "name": "Saint Vincent And Grenadines"
  },
  {
    "code": "ws",
    "name": "Samoa"
  },
  {
    "code": "sm",
    "name": "San Marino"
  },
  {
    "code": "st",
    "name": "Sao Tome And Principe"
  },
  {
    "code": "sa",
    "name": "Saudi Arabia"
  },
  {
    "code": "sn",
    "name": "Senegal"
  },
  {
    "code": "rs",
    "name": "Serbia"
  },
  {
    "code": "sc",
    "name": "Seychelles"
  },
  {
    "code": "sl",
    "name": "Sierra Leone"
  },
  {
    "code": "sg",
    "name": "Singapore"
  },
  {
    "code": "sk",
    "name": "Slovakia"
  },
  {
    "code": "si",
    "name": "Slovenia"
  },
  {
    "code": "sb",
    "name": "Solomon Islands"
  },
  {
    "code": "so",
    "name": "Somalia"
  },
  {
    "code": "za",
    "name": "South Africa"
  },
  {
    "code": "gs",
    "name": "South Georgia And Sandwich Isl."
  },
  {
    "code": "es",
    "name": "Spain"
  },
  {
    "code": "lk",
    "name": "Sri Lanka"
  },
  {
    "code": "sd",
    "name": "Sudan"
  },
  {
    "code": "sr",
    "name": "Suriname"
  },
  {
    "code": "sj",
    "name": "Svalbard And Jan Mayen"
  },
  {
    "code": "sz",
    "name": "Swaziland"
  },
  {
    "code": "se",
    "name": "Sweden"
  },
  {
    "code": "ch",
    "name": "Switzerland"
  },
  {
    "code": "sy",
    "name": "Syrian Arab Republic"
  },
  {
    "code": "tw",
    "name": "Taiwan"
  },
  {
    "code": "tj",
    "name": "Tajikistan"
  },
  {
    "code": "tz",
    "name": "Tanzania"
  },
  {
    "code": "th",
    "name": "Thailand"
  },
  {
    "code": "tl",
    "name": "Timor-Leste"
  },
  {
    "code": "tg",
    "name": "Togo"
  },
  {
    "code": "tk",
    "name": "Tokelau"
  },
  {
    "code": "to",
    "name": "Tonga"
  },
  {
    "code": "tt",
    "name": "Trinidad And Tobago"
  },
  {
    "code": "tn",
    "name": "Tunisia"
  },
  {
    "code": "tr",
    "name": "Turkey"
  },
  {
    "code": "tm",
    "name": "Turkmenistan"
  },
  {
    "code": "tc",
    "name": "Turks And Caicos Islands"
  },
  {
    "code": "tv",
    "name": "Tuvalu"
  },
  {
    "code": "ug",
    "name": "Uganda"
  },
  {
    "code": "ua",
    "name": "Ukraine"
  },
  {
    "code": "ae",
    "name": "United Arab Emirates"
  },
  {
    "code": "gb",
    "name": "United Kingdom"
  },
  {
    "code": "us",
    "name": "United States"
  },
  {
    "code": "um",
    "name": "United States Outlying Islands"
  },
  {
    "code": "uy",
    "name": "Uruguay"
  },
  {
    "code": "uz",
    "name": "Uzbekistan"
  },
  {
    "code": "vu",
    "name": "Vanuatu"
  },
  {
    "code": "ve",
    "name": "Venezuela"
  },
  {
    "code": "vn",
    "name": "Viet Nam"
  },
  {
    "code": "vg",
    "name": "Virgin Islands, British"
  },
  {
    "code": "vi",
    "name": "Virgin Islands, U.S."
  },
  {
    "code": "wf",
    "name": "Wallis And Futuna"
  },
  {
    "code": "eh",
    "name": "Western Sahara"
  },
  {
    "code": "ye",
    "name": "Yemen"
  },
  {
    "code": "zm",
    "name": "Zambia"
  },
  {
    "code": "zw",
    "name": "Zimbabwe"
  }
]
@djowinz

This comment has been minimized.

Show comment
Hide comment
@djowinz

djowinz Feb 15, 2017

This doesn't include North Korea... Be careful when just copy / pasting this.

djowinz commented Feb 15, 2017

This doesn't include North Korea... Be careful when just copy / pasting this.

@cdufault

This comment has been minimized.

Show comment
Hide comment
@cdufault

cdufault Jun 12, 2017

Updated to have proper North and South Korea's
var isoCountries = {
'Afghanistan': 'AF',
'Aland Islands': 'AX',
'Albania': 'AL',
'Algeria': 'DZ',
'American Samoa': 'AS',
'Andorra': 'AD',
'Angola': 'AO',
'Anguilla': 'AI',
'Antarctica': 'AQ',
'Antigua And Barbuda': 'AG',
'Argentina': 'AR',
'Armenia': 'AM',
'Aruba': 'AW',
'Australia': 'AU',
'Austria': 'AT',
'Azerbaijan': 'AZ',
'Bahamas': 'BS',
'Bahrain': 'BH',
'Bangladesh': 'BD',
'Barbados': 'BB',
'Belarus': 'BY',
'Belgium': 'BE',
'Belize': 'BZ',
'Benin': 'BJ',
'Bermuda': 'BM',
'Bhutan': 'BT',
'Bolivia': 'BO',
'Bosnia And Herzegovina': 'BA',
'Botswana': 'BW',
'Bouvet Island': 'BV',
'Brazil': 'BR',
'British Indian Ocean Territory': 'IO',
'Brunei Darussalam': 'BN',
'Bulgaria': 'BG',
'Burkina Faso': 'BF',
'Burundi': 'BI',
'Cambodia': 'KH',
'Cameroon': 'CM',
'Canada': 'CA',
'Cape Verde': 'CV',
'Cayman Islands': 'KY',
'Central African Republic': 'CF',
'Chad': 'TD',
'Chile': 'CL',
'China': 'CN',
'Christmas Island': 'CX',
'Cocos (Keeling) Islands': 'CC',
'Colombia': 'CO',
'Comoros': 'KM',
'Congo': 'CG',
'Congo, Democratic Republic': 'CD',
'Cook Islands': 'CK',
'Costa Rica': 'CR',
'Cote D'Ivoire': 'CI',
'Croatia': 'HR',
'Cuba': 'CU',
'Cyprus': 'CY',
'Czech Republic': 'CZ',
'Denmark': 'DK',
'Djibouti': 'DJ',
'Dominica': 'DM',
'Dominican Republic': 'DO',
'Ecuador': 'EC',
'Egypt': 'EG',
'El Salvador': 'SV',
'Equatorial Guinea': 'GQ',
'Eritrea': 'ER',
'Estonia': 'EE',
'Ethiopia': 'ET',
'Falkland Islands': 'FK',
'Faroe Islands': 'FO',
'Fiji': 'FJ',
'Finland': 'FI',
'France': 'FR',
'French Guiana': 'GF',
'French Polynesia': 'PF',
'French Southern Territories': 'TF',
'Gabon': 'GA',
'Gambia': 'GM',
'Georgia': 'GE',
'Germany': 'DE',
'Ghana': 'GH',
'Gibraltar': 'GI',
'Greece': 'GR',
'Greenland': 'GL',
'Grenada': 'GD',
'Guadeloupe': 'GP',
'Guam': 'GU',
'Guatemala': 'GT',
'Guernsey': 'GG',
'Guinea': 'GN',
'Guinea-Bissau': 'GW',
'Guyana': 'GY',
'Haiti': 'HT',
'Heard Island & Mcdonald Islands': 'HM',
'Holy See (Vatican City State)': 'VA',
'Honduras': 'HN',
'Hong Kong': 'HK',
'Hungary': 'HU',
'Iceland': 'IS',
'India': 'IN',
'Indonesia': 'ID',
'Iran, Islamic Republic Of': 'IR',
'Iraq': 'IQ',
'Ireland': 'IE',
'Isle Of Man': 'IM',
'Israel': 'IL',
'Italy': 'IT',
'Jamaica': 'JM',
'Japan': 'JP',
'Jersey': 'JE',
'Jordan': 'JO',
'Kazakhstan': 'KZ',
'Kenya': 'KE',
'Kiribati': 'KI',
'Republic of Korea': 'KR',
'South Korea': 'KR',
"Democratic People's Republic of Korea": 'KP',
'North Korea': 'KP',
'Kuwait': 'KW',
'Kyrgyzstan': 'KG',
'Lao People's Democratic Republic': 'LA',
'Latvia': 'LV',
'Lebanon': 'LB',
'Lesotho': 'LS',
'Liberia': 'LR',
'Libyan Arab Jamahiriya': 'LY',
'Liechtenstein': 'LI',
'Lithuania': 'LT',
'Luxembourg': 'LU',
'Macao': 'MO',
'Macedonia': 'MK',
'Madagascar': 'MG',
'Malawi': 'MW',
'Malaysia': 'MY',
'Maldives': 'MV',
'Mali': 'ML',
'Malta': 'MT',
'Marshall Islands': 'MH',
'Martinique': 'MQ',
'Mauritania': 'MR',
'Mauritius': 'MU',
'Mayotte': 'YT',
'Mexico': 'MX',
'Micronesia, Federated States Of': 'FM',
'Moldova': 'MD',
'Monaco': 'MC',
'Mongolia': 'MN',
'Montenegro': 'ME',
'Montserrat': 'MS',
'Morocco': 'MA',
'Mozambique': 'MZ',
'Myanmar': 'MM',
'Namibia': 'NA',
'Nauru': 'NR',
'Nepal': 'NP',
'Netherlands': 'NL',
'Netherlands Antilles': 'AN',
'New Caledonia': 'NC',
'New Zealand': 'NZ',
'Nicaragua': 'NI',
'Niger': 'NE',
'Nigeria': 'NG',
'Niue': 'NU',
'Norfolk Island': 'NF',
'Northern Mariana Islands': 'MP',
'Norway': 'NO',
'Oman': 'OM',
'Pakistan': 'PK',
'Palau': 'PW',
'Palestinian Territory, Occupied': 'PS',
'Panama': 'PA',
'Papua New Guinea': 'PG',
'Paraguay': 'PY',
'Peru': 'PE',
'Philippines': 'PH',
'Pitcairn': 'PN',
'Poland': 'PL',
'Portugal': 'PT',
'Puerto Rico': 'PR',
'Qatar': 'QA',
'Reunion': 'RE',
'Romania': 'RO',
'Russian Federation': 'RU',
'Rwanda': 'RW',
'Saint Barthelemy': 'BL',
'Saint Helena': 'SH',
'Saint Kitts And Nevis': 'KN',
'Saint Lucia': 'LC',
'Saint Martin': 'MF',
'Saint Pierre And Miquelon': 'PM',
'Saint Vincent And Grenadines': 'VC',
'Samoa': 'WS',
'San Marino': 'SM',
'Sao Tome And Principe': 'ST',
'Saudi Arabia': 'SA',
'Senegal': 'SN',
'Serbia': 'RS',
'Seychelles': 'SC',
'Sierra Leone': 'SL',
'Singapore': 'SG',
'Slovakia': 'SK',
'Slovenia': 'SI',
'Solomon Islands': 'SB',
'Somalia': 'SO',
'South Africa': 'ZA',
'South Georgia And Sandwich Isl.': 'GS',
'Spain': 'ES',
'Sri Lanka': 'LK',
'Sudan': 'SD',
'Suriname': 'SR',
'Svalbard And Jan Mayen': 'SJ',
'Swaziland': 'SZ',
'Sweden': 'SE',
'Switzerland': 'CH',
'Syrian Arab Republic': 'SY',
'Taiwan': 'TW',
'Tajikistan': 'TJ',
'Tanzania': 'TZ',
'Thailand': 'TH',
'Timor-Leste': 'TL',
'Togo': 'TG',
'Tokelau': 'TK',
'Tonga': 'TO',
'Trinidad And Tobago': 'TT',
'Tunisia': 'TN',
'Turkey': 'TR',
'Turkmenistan': 'TM',
'Turks And Caicos Islands': 'TC',
'Tuvalu': 'TV',
'Uganda': 'UG',
'Ukraine': 'UA',
'United Arab Emirates': 'AE',
'United Kingdom': 'GB',
'United States': 'US',
'United States Outlying Islands': 'UM',
'Uruguay': 'UY',
'Uzbekistan': 'UZ',
'Vanuatu': 'VU',
'Venezuela': 'VE',
'Vietnam': 'VN',
'Virgin Islands, British': 'VG',
'Virgin Islands, U.S.': 'VI',
'Wallis And Futuna': 'WF',
'Western Sahara': 'EH',
'Yemen': 'YE',
'Zambia': 'ZM',
'Zimbabwe': 'ZW'
};

cdufault commented Jun 12, 2017

Updated to have proper North and South Korea's
var isoCountries = {
'Afghanistan': 'AF',
'Aland Islands': 'AX',
'Albania': 'AL',
'Algeria': 'DZ',
'American Samoa': 'AS',
'Andorra': 'AD',
'Angola': 'AO',
'Anguilla': 'AI',
'Antarctica': 'AQ',
'Antigua And Barbuda': 'AG',
'Argentina': 'AR',
'Armenia': 'AM',
'Aruba': 'AW',
'Australia': 'AU',
'Austria': 'AT',
'Azerbaijan': 'AZ',
'Bahamas': 'BS',
'Bahrain': 'BH',
'Bangladesh': 'BD',
'Barbados': 'BB',
'Belarus': 'BY',
'Belgium': 'BE',
'Belize': 'BZ',
'Benin': 'BJ',
'Bermuda': 'BM',
'Bhutan': 'BT',
'Bolivia': 'BO',
'Bosnia And Herzegovina': 'BA',
'Botswana': 'BW',
'Bouvet Island': 'BV',
'Brazil': 'BR',
'British Indian Ocean Territory': 'IO',
'Brunei Darussalam': 'BN',
'Bulgaria': 'BG',
'Burkina Faso': 'BF',
'Burundi': 'BI',
'Cambodia': 'KH',
'Cameroon': 'CM',
'Canada': 'CA',
'Cape Verde': 'CV',
'Cayman Islands': 'KY',
'Central African Republic': 'CF',
'Chad': 'TD',
'Chile': 'CL',
'China': 'CN',
'Christmas Island': 'CX',
'Cocos (Keeling) Islands': 'CC',
'Colombia': 'CO',
'Comoros': 'KM',
'Congo': 'CG',
'Congo, Democratic Republic': 'CD',
'Cook Islands': 'CK',
'Costa Rica': 'CR',
'Cote D'Ivoire': 'CI',
'Croatia': 'HR',
'Cuba': 'CU',
'Cyprus': 'CY',
'Czech Republic': 'CZ',
'Denmark': 'DK',
'Djibouti': 'DJ',
'Dominica': 'DM',
'Dominican Republic': 'DO',
'Ecuador': 'EC',
'Egypt': 'EG',
'El Salvador': 'SV',
'Equatorial Guinea': 'GQ',
'Eritrea': 'ER',
'Estonia': 'EE',
'Ethiopia': 'ET',
'Falkland Islands': 'FK',
'Faroe Islands': 'FO',
'Fiji': 'FJ',
'Finland': 'FI',
'France': 'FR',
'French Guiana': 'GF',
'French Polynesia': 'PF',
'French Southern Territories': 'TF',
'Gabon': 'GA',
'Gambia': 'GM',
'Georgia': 'GE',
'Germany': 'DE',
'Ghana': 'GH',
'Gibraltar': 'GI',
'Greece': 'GR',
'Greenland': 'GL',
'Grenada': 'GD',
'Guadeloupe': 'GP',
'Guam': 'GU',
'Guatemala': 'GT',
'Guernsey': 'GG',
'Guinea': 'GN',
'Guinea-Bissau': 'GW',
'Guyana': 'GY',
'Haiti': 'HT',
'Heard Island & Mcdonald Islands': 'HM',
'Holy See (Vatican City State)': 'VA',
'Honduras': 'HN',
'Hong Kong': 'HK',
'Hungary': 'HU',
'Iceland': 'IS',
'India': 'IN',
'Indonesia': 'ID',
'Iran, Islamic Republic Of': 'IR',
'Iraq': 'IQ',
'Ireland': 'IE',
'Isle Of Man': 'IM',
'Israel': 'IL',
'Italy': 'IT',
'Jamaica': 'JM',
'Japan': 'JP',
'Jersey': 'JE',
'Jordan': 'JO',
'Kazakhstan': 'KZ',
'Kenya': 'KE',
'Kiribati': 'KI',
'Republic of Korea': 'KR',
'South Korea': 'KR',
"Democratic People's Republic of Korea": 'KP',
'North Korea': 'KP',
'Kuwait': 'KW',
'Kyrgyzstan': 'KG',
'Lao People's Democratic Republic': 'LA',
'Latvia': 'LV',
'Lebanon': 'LB',
'Lesotho': 'LS',
'Liberia': 'LR',
'Libyan Arab Jamahiriya': 'LY',
'Liechtenstein': 'LI',
'Lithuania': 'LT',
'Luxembourg': 'LU',
'Macao': 'MO',
'Macedonia': 'MK',
'Madagascar': 'MG',
'Malawi': 'MW',
'Malaysia': 'MY',
'Maldives': 'MV',
'Mali': 'ML',
'Malta': 'MT',
'Marshall Islands': 'MH',
'Martinique': 'MQ',
'Mauritania': 'MR',
'Mauritius': 'MU',
'Mayotte': 'YT',
'Mexico': 'MX',
'Micronesia, Federated States Of': 'FM',
'Moldova': 'MD',
'Monaco': 'MC',
'Mongolia': 'MN',
'Montenegro': 'ME',
'Montserrat': 'MS',
'Morocco': 'MA',
'Mozambique': 'MZ',
'Myanmar': 'MM',
'Namibia': 'NA',
'Nauru': 'NR',
'Nepal': 'NP',
'Netherlands': 'NL',
'Netherlands Antilles': 'AN',
'New Caledonia': 'NC',
'New Zealand': 'NZ',
'Nicaragua': 'NI',
'Niger': 'NE',
'Nigeria': 'NG',
'Niue': 'NU',
'Norfolk Island': 'NF',
'Northern Mariana Islands': 'MP',
'Norway': 'NO',
'Oman': 'OM',
'Pakistan': 'PK',
'Palau': 'PW',
'Palestinian Territory, Occupied': 'PS',
'Panama': 'PA',
'Papua New Guinea': 'PG',
'Paraguay': 'PY',
'Peru': 'PE',
'Philippines': 'PH',
'Pitcairn': 'PN',
'Poland': 'PL',
'Portugal': 'PT',
'Puerto Rico': 'PR',
'Qatar': 'QA',
'Reunion': 'RE',
'Romania': 'RO',
'Russian Federation': 'RU',
'Rwanda': 'RW',
'Saint Barthelemy': 'BL',
'Saint Helena': 'SH',
'Saint Kitts And Nevis': 'KN',
'Saint Lucia': 'LC',
'Saint Martin': 'MF',
'Saint Pierre And Miquelon': 'PM',
'Saint Vincent And Grenadines': 'VC',
'Samoa': 'WS',
'San Marino': 'SM',
'Sao Tome And Principe': 'ST',
'Saudi Arabia': 'SA',
'Senegal': 'SN',
'Serbia': 'RS',
'Seychelles': 'SC',
'Sierra Leone': 'SL',
'Singapore': 'SG',
'Slovakia': 'SK',
'Slovenia': 'SI',
'Solomon Islands': 'SB',
'Somalia': 'SO',
'South Africa': 'ZA',
'South Georgia And Sandwich Isl.': 'GS',
'Spain': 'ES',
'Sri Lanka': 'LK',
'Sudan': 'SD',
'Suriname': 'SR',
'Svalbard And Jan Mayen': 'SJ',
'Swaziland': 'SZ',
'Sweden': 'SE',
'Switzerland': 'CH',
'Syrian Arab Republic': 'SY',
'Taiwan': 'TW',
'Tajikistan': 'TJ',
'Tanzania': 'TZ',
'Thailand': 'TH',
'Timor-Leste': 'TL',
'Togo': 'TG',
'Tokelau': 'TK',
'Tonga': 'TO',
'Trinidad And Tobago': 'TT',
'Tunisia': 'TN',
'Turkey': 'TR',
'Turkmenistan': 'TM',
'Turks And Caicos Islands': 'TC',
'Tuvalu': 'TV',
'Uganda': 'UG',
'Ukraine': 'UA',
'United Arab Emirates': 'AE',
'United Kingdom': 'GB',
'United States': 'US',
'United States Outlying Islands': 'UM',
'Uruguay': 'UY',
'Uzbekistan': 'UZ',
'Vanuatu': 'VU',
'Venezuela': 'VE',
'Vietnam': 'VN',
'Virgin Islands, British': 'VG',
'Virgin Islands, U.S.': 'VI',
'Wallis And Futuna': 'WF',
'Western Sahara': 'EH',
'Yemen': 'YE',
'Zambia': 'ZM',
'Zimbabwe': 'ZW'
};

@alrms

This comment has been minimized.

Show comment
Hide comment
@alrms

alrms Jun 22, 2017

That's great but i was wondering if we can transform the object to a function that returns this object ;)?

alrms commented Jun 22, 2017

That's great but i was wondering if we can transform the object to a function that returns this object ;)?

@kspearrin

This comment has been minimized.

Show comment
Hide comment
@kspearrin

kspearrin Oct 18, 2017

Lowercase name => code mapping:

var isoCountries = {
  afghanistan: "AF",
  "aland islands": "AX",
  albania: "AL",
  algeria: "DZ",
  "american samoa": "AS",
  andorra: "AD",
  angola: "AO",
  anguilla: "AI",
  antarctica: "AQ",
  "antigua and barbuda": "AG",
  argentina: "AR",
  armenia: "AM",
  aruba: "AW",
  australia: "AU",
  austria: "AT",
  azerbaijan: "AZ",
  bahamas: "BS",
  bahrain: "BH",
  bangladesh: "BD",
  barbados: "BB",
  belarus: "BY",
  belgium: "BE",
  belize: "BZ",
  benin: "BJ",
  bermuda: "BM",
  bhutan: "BT",
  bolivia: "BO",
  "bosnia and herzegovina": "BA",
  botswana: "BW",
  "bouvet island": "BV",
  brazil: "BR",
  "british indian ocean territory": "IO",
  "brunei darussalam": "BN",
  bulgaria: "BG",
  "burkina faso": "BF",
  burundi: "BI",
  cambodia: "KH",
  cameroon: "CM",
  canada: "CA",
  "cape verde": "CV",
  "cayman islands": "KY",
  "central african republic": "CF",
  chad: "TD",
  chile: "CL",
  china: "CN",
  "christmas island": "CX",
  "cocos (keeling) islands": "CC",
  colombia: "CO",
  comoros: "KM",
  congo: "CG",
  "congo, democratic republic": "CD",
  "cook islands": "CK",
  "costa rica": "CR",
  "cote d'ivoire": "CI",
  croatia: "HR",
  cuba: "CU",
  cyprus: "CY",
  "czech republic": "CZ",
  denmark: "DK",
  djibouti: "DJ",
  dominica: "DM",
  "dominican republic": "DO",
  ecuador: "EC",
  egypt: "EG",
  "el salvador": "SV",
  "equatorial guinea": "GQ",
  eritrea: "ER",
  estonia: "EE",
  ethiopia: "ET",
  "falkland islands": "FK",
  "faroe islands": "FO",
  fiji: "FJ",
  finland: "FI",
  france: "FR",
  "french guiana": "GF",
  "french polynesia": "PF",
  "french southern territories": "TF",
  gabon: "GA",
  gambia: "GM",
  georgia: "GE",
  germany: "DE",
  ghana: "GH",
  gibraltar: "GI",
  greece: "GR",
  greenland: "GL",
  grenada: "GD",
  guadeloupe: "GP",
  guam: "GU",
  guatemala: "GT",
  guernsey: "GG",
  guinea: "GN",
  "guinea-bissau": "GW",
  guyana: "GY",
  haiti: "HT",
  "heard island & mcdonald islands": "HM",
  "holy see (vatican city state)": "VA",
  honduras: "HN",
  "hong kong": "HK",
  hungary: "HU",
  iceland: "IS",
  india: "IN",
  indonesia: "ID",
  "iran, islamic republic of": "IR",
  iraq: "IQ",
  ireland: "IE",
  "isle of man": "IM",
  israel: "IL",
  italy: "IT",
  jamaica: "JM",
  japan: "JP",
  jersey: "JE",
  jordan: "JO",
  kazakhstan: "KZ",
  kenya: "KE",
  kiribati: "KI",
  "republic of korea": "KR",
  "south korea": "KR",
  "democratic people's republic of korea": "KP",
  "north korea": "KP",
  kuwait: "KW",
  kyrgyzstan: "KG",
  "lao people's democratic republic": "LA",
  latvia: "LV",
  lebanon: "LB",
  lesotho: "LS",
  liberia: "LR",
  "libyan arab jamahiriya": "LY",
  liechtenstein: "LI",
  lithuania: "LT",
  luxembourg: "LU",
  macao: "MO",
  macedonia: "MK",
  madagascar: "MG",
  malawi: "MW",
  malaysia: "MY",
  maldives: "MV",
  mali: "ML",
  malta: "MT",
  "marshall islands": "MH",
  martinique: "MQ",
  mauritania: "MR",
  mauritius: "MU",
  mayotte: "YT",
  mexico: "MX",
  "micronesia, federated states of": "FM",
  moldova: "MD",
  monaco: "MC",
  mongolia: "MN",
  montenegro: "ME",
  montserrat: "MS",
  morocco: "MA",
  mozambique: "MZ",
  myanmar: "MM",
  namibia: "NA",
  nauru: "NR",
  nepal: "NP",
  netherlands: "NL",
  "netherlands antilles": "AN",
  "new caledonia": "NC",
  "new zealand": "NZ",
  nicaragua: "NI",
  niger: "NE",
  nigeria: "NG",
  niue: "NU",
  "norfolk island": "NF",
  "northern mariana islands": "MP",
  norway: "NO",
  oman: "OM",
  pakistan: "PK",
  palau: "PW",
  "palestinian territory, occupied": "PS",
  panama: "PA",
  "papua new guinea": "PG",
  paraguay: "PY",
  peru: "PE",
  philippines: "PH",
  pitcairn: "PN",
  poland: "PL",
  portugal: "PT",
  "puerto rico": "PR",
  qatar: "QA",
  reunion: "RE",
  romania: "RO",
  "russian federation": "RU",
  rwanda: "RW",
  "saint barthelemy": "BL",
  "saint helena": "SH",
  "saint kitts and nevis": "KN",
  "saint lucia": "LC",
  "saint martin": "MF",
  "saint pierre and miquelon": "PM",
  "saint vincent and grenadines": "VC",
  samoa: "WS",
  "san marino": "SM",
  "sao tome and principe": "ST",
  "saudi arabia": "SA",
  senegal: "SN",
  serbia: "RS",
  seychelles: "SC",
  "sierra leone": "SL",
  singapore: "SG",
  slovakia: "SK",
  slovenia: "SI",
  "solomon islands": "SB",
  somalia: "SO",
  "south africa": "ZA",
  "south georgia and sandwich isl.": "GS",
  spain: "ES",
  "sri lanka": "LK",
  sudan: "SD",
  suriname: "SR",
  "svalbard and jan mayen": "SJ",
  swaziland: "SZ",
  sweden: "SE",
  switzerland: "CH",
  "syrian arab republic": "SY",
  taiwan: "TW",
  tajikistan: "TJ",
  tanzania: "TZ",
  thailand: "TH",
  "timor-leste": "TL",
  togo: "TG",
  tokelau: "TK",
  tonga: "TO",
  "trinidad and tobago": "TT",
  tunisia: "TN",
  turkey: "TR",
  turkmenistan: "TM",
  "turks and caicos islands": "TC",
  tuvalu: "TV",
  uganda: "UG",
  ukraine: "UA",
  "united arab emirates": "AE",
  "united kingdom": "GB",
  "united states": "US",
  "united states outlying islands": "UM",
  uruguay: "UY",
  uzbekistan: "UZ",
  vanuatu: "VU",
  venezuela: "VE",
  vietnam: "VN",
  "virgin islands, british": "VG",
  "virgin islands, u.s.": "VI",
  "wallis and futuna": "WF",
  "western sahara": "EH",
  yemen: "YE",
  zambia: "ZM",
  zimbabwe: "ZW"
};

kspearrin commented Oct 18, 2017

Lowercase name => code mapping:

var isoCountries = {
  afghanistan: "AF",
  "aland islands": "AX",
  albania: "AL",
  algeria: "DZ",
  "american samoa": "AS",
  andorra: "AD",
  angola: "AO",
  anguilla: "AI",
  antarctica: "AQ",
  "antigua and barbuda": "AG",
  argentina: "AR",
  armenia: "AM",
  aruba: "AW",
  australia: "AU",
  austria: "AT",
  azerbaijan: "AZ",
  bahamas: "BS",
  bahrain: "BH",
  bangladesh: "BD",
  barbados: "BB",
  belarus: "BY",
  belgium: "BE",
  belize: "BZ",
  benin: "BJ",
  bermuda: "BM",
  bhutan: "BT",
  bolivia: "BO",
  "bosnia and herzegovina": "BA",
  botswana: "BW",
  "bouvet island": "BV",
  brazil: "BR",
  "british indian ocean territory": "IO",
  "brunei darussalam": "BN",
  bulgaria: "BG",
  "burkina faso": "BF",
  burundi: "BI",
  cambodia: "KH",
  cameroon: "CM",
  canada: "CA",
  "cape verde": "CV",
  "cayman islands": "KY",
  "central african republic": "CF",
  chad: "TD",
  chile: "CL",
  china: "CN",
  "christmas island": "CX",
  "cocos (keeling) islands": "CC",
  colombia: "CO",
  comoros: "KM",
  congo: "CG",
  "congo, democratic republic": "CD",
  "cook islands": "CK",
  "costa rica": "CR",
  "cote d'ivoire": "CI",
  croatia: "HR",
  cuba: "CU",
  cyprus: "CY",
  "czech republic": "CZ",
  denmark: "DK",
  djibouti: "DJ",
  dominica: "DM",
  "dominican republic": "DO",
  ecuador: "EC",
  egypt: "EG",
  "el salvador": "SV",
  "equatorial guinea": "GQ",
  eritrea: "ER",
  estonia: "EE",
  ethiopia: "ET",
  "falkland islands": "FK",
  "faroe islands": "FO",
  fiji: "FJ",
  finland: "FI",
  france: "FR",
  "french guiana": "GF",
  "french polynesia": "PF",
  "french southern territories": "TF",
  gabon: "GA",
  gambia: "GM",
  georgia: "GE",
  germany: "DE",
  ghana: "GH",
  gibraltar: "GI",
  greece: "GR",
  greenland: "GL",
  grenada: "GD",
  guadeloupe: "GP",
  guam: "GU",
  guatemala: "GT",
  guernsey: "GG",
  guinea: "GN",
  "guinea-bissau": "GW",
  guyana: "GY",
  haiti: "HT",
  "heard island & mcdonald islands": "HM",
  "holy see (vatican city state)": "VA",
  honduras: "HN",
  "hong kong": "HK",
  hungary: "HU",
  iceland: "IS",
  india: "IN",
  indonesia: "ID",
  "iran, islamic republic of": "IR",
  iraq: "IQ",
  ireland: "IE",
  "isle of man": "IM",
  israel: "IL",
  italy: "IT",
  jamaica: "JM",
  japan: "JP",
  jersey: "JE",
  jordan: "JO",
  kazakhstan: "KZ",
  kenya: "KE",
  kiribati: "KI",
  "republic of korea": "KR",
  "south korea": "KR",
  "democratic people's republic of korea": "KP",
  "north korea": "KP",
  kuwait: "KW",
  kyrgyzstan: "KG",
  "lao people's democratic republic": "LA",
  latvia: "LV",
  lebanon: "LB",
  lesotho: "LS",
  liberia: "LR",
  "libyan arab jamahiriya": "LY",
  liechtenstein: "LI",
  lithuania: "LT",
  luxembourg: "LU",
  macao: "MO",
  macedonia: "MK",
  madagascar: "MG",
  malawi: "MW",
  malaysia: "MY",
  maldives: "MV",
  mali: "ML",
  malta: "MT",
  "marshall islands": "MH",
  martinique: "MQ",
  mauritania: "MR",
  mauritius: "MU",
  mayotte: "YT",
  mexico: "MX",
  "micronesia, federated states of": "FM",
  moldova: "MD",
  monaco: "MC",
  mongolia: "MN",
  montenegro: "ME",
  montserrat: "MS",
  morocco: "MA",
  mozambique: "MZ",
  myanmar: "MM",
  namibia: "NA",
  nauru: "NR",
  nepal: "NP",
  netherlands: "NL",
  "netherlands antilles": "AN",
  "new caledonia": "NC",
  "new zealand": "NZ",
  nicaragua: "NI",
  niger: "NE",
  nigeria: "NG",
  niue: "NU",
  "norfolk island": "NF",
  "northern mariana islands": "MP",
  norway: "NO",
  oman: "OM",
  pakistan: "PK",
  palau: "PW",
  "palestinian territory, occupied": "PS",
  panama: "PA",
  "papua new guinea": "PG",
  paraguay: "PY",
  peru: "PE",
  philippines: "PH",
  pitcairn: "PN",
  poland: "PL",
  portugal: "PT",
  "puerto rico": "PR",
  qatar: "QA",
  reunion: "RE",
  romania: "RO",
  "russian federation": "RU",
  rwanda: "RW",
  "saint barthelemy": "BL",
  "saint helena": "SH",
  "saint kitts and nevis": "KN",
  "saint lucia": "LC",
  "saint martin": "MF",
  "saint pierre and miquelon": "PM",
  "saint vincent and grenadines": "VC",
  samoa: "WS",
  "san marino": "SM",
  "sao tome and principe": "ST",
  "saudi arabia": "SA",
  senegal: "SN",
  serbia: "RS",
  seychelles: "SC",
  "sierra leone": "SL",
  singapore: "SG",
  slovakia: "SK",
  slovenia: "SI",
  "solomon islands": "SB",
  somalia: "SO",
  "south africa": "ZA",
  "south georgia and sandwich isl.": "GS",
  spain: "ES",
  "sri lanka": "LK",
  sudan: "SD",
  suriname: "SR",
  "svalbard and jan mayen": "SJ",
  swaziland: "SZ",
  sweden: "SE",
  switzerland: "CH",
  "syrian arab republic": "SY",
  taiwan: "TW",
  tajikistan: "TJ",
  tanzania: "TZ",
  thailand: "TH",
  "timor-leste": "TL",
  togo: "TG",
  tokelau: "TK",
  tonga: "TO",
  "trinidad and tobago": "TT",
  tunisia: "TN",
  turkey: "TR",
  turkmenistan: "TM",
  "turks and caicos islands": "TC",
  tuvalu: "TV",
  uganda: "UG",
  ukraine: "UA",
  "united arab emirates": "AE",
  "united kingdom": "GB",
  "united states": "US",
  "united states outlying islands": "UM",
  uruguay: "UY",
  uzbekistan: "UZ",
  vanuatu: "VU",
  venezuela: "VE",
  vietnam: "VN",
  "virgin islands, british": "VG",
  "virgin islands, u.s.": "VI",
  "wallis and futuna": "WF",
  "western sahara": "EH",
  yemen: "YE",
  zambia: "ZM",
  zimbabwe: "ZW"
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment