Skip to content

Instantly share code, notes, and snippets.

@henrik
Last active December 20, 2023 12:20
Show Gist options
  • Save henrik/1688572 to your computer and use it in GitHub Desktop.
Save henrik/1688572 to your computer and use it in GitHub Desktop.
EU (European Union) country codes, ISO 3166-1 alpha-2. (This Gist is from 2012. Please see comments for updates.)
# Note: VAT identification numbers for Greece use "EL", not "GR".
COUNTRY_CODES_EU = %w[
AT BE BG CY CZ DK EE FI FR DE GR HU IE IT
LV LT LU MT NL PL PT RO SK SI ES SE GB
]
@jugmac00
Copy link

@ArminCoder
Copy link

Here's a list in javascript array :
const europeArray = ['AL','AD','AT','AZ','BY','BE','BA','BG','HR','CY','CZ','DK','EE','FI','FR','GE','DE','GR','HU','IS','IE', 'IT','KZ','XK','LV','LI','LT','LU','MK','MT','MD','MC','ME','NL','NO','PL','PT','RO','RU','SM','RS','SK', 'SI','ES','SE','CH','TR','UA','GB','VA' ];

@maxpelic
Copy link

This is great! Here's a list that can be used with AMP:
["al","ad","at","az","by","be","ba","bg","hr","cy","cz","dk","ee","fi","fr","ge","de","gr","hu","is","ie", "it","kz","xk","lv","li","lt","lu","mk","mt","md","mc","me","nl","no","pl","pt","ro","ru","sm","rs","sk", "si","es","se","ch","tr","ua","gb","va"]

@KevinCuddeback
Copy link

  1. Why isn't this discussion just referenceing ISO-3166 alpha-2? Is the idea that you want to be able to tell from the code whether a jurisdiction is "in" the EU?, and where, for example, "Ceuta and Melilla" == "EA"
    https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Current_codes

  2. Would including "EU" blow people's minds? I ask because I'd be using this list to identify "jurisdiction of incorporation" and the EU now allows pan-European incorporation. See:
    https://en.wikipedia.org/wiki/List_of_legal_entity_types_by_country#European_Economic_Area_(including_the_European_Union)

@AdamGerthel
Copy link

@ArminCoder that list includes non EU countries as well, which is not what the original gist is about.

@ArminCoder
Copy link

ArminCoder commented Jul 3, 2019

@AdamGerthel , yeah I taught it was about Europe countries, not just the ones in European Union. The array I provided are all the countries that are in Europe.

@CErika
Copy link

CErika commented Jul 23, 2019

Here it is the EU country on a JSON with the ISO 3166 1 alpha2
{ "Austria": "AT", "Belgium": "BE", "Bulgaria": "BG", "Croatia": "HR", "Cyprus": "CY", "Czech Republic": "CZ", "Denmark": "DK", "Estonia": "EE", "Finland":"FI", "France": "FR", "Germany": "DE", "Greece": "GR", "Hungary": "HU", "Ireland": "IE", "Italy": "IT", "Latvia": "LV", "Lithuania": "LT", "Luxembourg": "LU", "Malta": "MT", "Netherlands": "NL", "Poland": "PL", "Portugal": "PT", "Romania": "RO", "San Marino": "SM", "Slovakia": "SK", "Slovenia": "SI", "Spain": "ES", "Sweden": "SE", "United Kingdom": "GB", "Vatican City": "VA" }

@qmcree
Copy link

qmcree commented Dec 3, 2019

@glesperance's list looked most complete, so here it is as a PHP array:

private const EUROPEAN_COUNTRY_CODES = [
    // -----[ EU 28 ]-----
    "AT", // Austria
    "BE", // Belgium
    "BG", // Bulgaria
    "HR", // Croatia
    "CY", // Cyprus
    "CZ", // Czech Republic
    "DK", // Denmark
    "EE", // Estonia
    "FI", // Finland
    "FR", // France
    "DE", // Germany
    "GR", // Greece
    "HU", // Hungary
    "IE", // Ireland, Republic of (EIRE)
    "IT", // Italy
    "LV", // Latvia
    "LT", // Lithuania
    "LU", // Luxembourg
    "MT", // Malta
    "NL", // Netherlands
    "PL", // Poland
    "PT", // Portugal
    "RO", // Romania
    "SK", // Slovakia
    "SI", // Slovenia
    "ES", // Spain
    "SE", // Sweden
    "GB", // United Kingdom (Great Britain)

    // -----[ Outermost Regions (OMR) ]------
    "GF", // French Guiana
    "GP", // Guadeloupe
    "MQ", // Martinique
    "ME", // Montenegro
    "YT", // Mayotte
    "RE", // Réunion
    "MF", // Saint Martin

    // -----[ Special Cases: Part of EU ]-----
    "GI", // Gibraltar
    "AX", // Åland Islands

    // -----[ Overseas Countries and Territories (OCT) ]-----
    "PM", // Saint Pierre and Miquelon
    "GL", // Greenland
    "BL", // Saint Bartelemey
    "SX", // Sint Maarten
    "AW", // Aruba
    "CW", // Curacao
    "WF", // Wallis and Futuna
    "PF", // French Polynesia
    "NC", // New Caledonia
    "TF", // French Southern Territories
    "AI", // Anguilla
    "BM", // Bermuda
    "IO", // British Indian Ocean Territory
    "VG", // Virgin Islands, British
    "KY", // Cayman Islands
    "FK", // Falkland Islands (Malvinas)
    "MS", // Montserrat
    "PN", // Pitcairn
    "SH", // Saint Helena
    "GS", // South Georgia and the South Sandwich Islands
    "TC", // Turks and Caicos Islands

    // -----[ Microstates ]-----
    "AD", // Andorra
    "LI", // Liechtenstein
    "MC", // Monaco
    "SM", // San Marino
    "VA", // Vatican City

    // -----[ Other ]-----
    "JE", // Jersey
    "GG", // Guernsey
];

@MikeWebMeridianM2
Copy link

AL
AD
AT
AZ
BY
BE
BA
BG
HR
CY
CZ
DK
EE
FI
FR
GE
DE
GR
HU
IS
IE
IT
KZ
XK
LV
LI
LT
LU
MK
MT
MD
MC
ME
NL
NO
PL
PT
RO
RU
SM
RS
SK
SI
ES
SE
CH
TR
UA
GB
VA

@plpepin
Copy link

plpepin commented Jan 21, 2020

Based on hussainrmdxb's post, here's one for a shortcode for example:
"AT,BE,HR,BG,CY,CZ,DK,EE,FI,FR,DE,GR,HU,IE,IT,LV,LT,LU,MT,NL,PL,PT,RO,SK,SI,ES,SE,GB"

@josuedjh3
Copy link

josuedjh3 commented Nov 25, 2020

class G8Countries(Countries):
    # fmt: off
    only = [
        "AT", "BE", "BG", "CY", "CZ",
        "DE", "DK", "EE", "ES", "FI",
        "FR", "GR", "HR", "HU", "IE",
        "IT", "LT", "LU", "LV", "MT",
        "NL", "PL", "PT", "RO", "SE",
        "SI", "SK"
    ]
    # fmt: on

Lista de paises de la unión europea. Espero que les sirva.

@bigghe
Copy link

bigghe commented Mar 23, 2021

@glesperance's list looked most complete, so here it is as a PHP array:

private const EUROPEAN_COUNTRY_CODES = [
    // -----[ EU 28 ]-----
    "AT", // Austria
    "BE", // Belgium
    "BG", // Bulgaria
    "HR", // Croatia
    "CY", // Cyprus
    "CZ", // Czech Republic
    "DK", // Denmark
    "EE", // Estonia
    "FI", // Finland
    "FR", // France
    "DE", // Germany
    "GR", // Greece
    "HU", // Hungary
    "IE", // Ireland, Republic of (EIRE)
    "IT", // Italy
    "LV", // Latvia
    "LT", // Lithuania
    "LU", // Luxembourg
    "MT", // Malta
    "NL", // Netherlands
    "PL", // Poland
    "PT", // Portugal
    "RO", // Romania
    "SK", // Slovakia
    "SI", // Slovenia
    "ES", // Spain
    "SE", // Sweden
    "GB", // United Kingdom (Great Britain)

    // -----[ Outermost Regions (OMR) ]------
    "GF", // French Guiana
    "GP", // Guadeloupe
    "MQ", // Martinique
    "ME", // Montenegro
    "YT", // Mayotte
    "RE", // Réunion
    "MF", // Saint Martin

    // -----[ Special Cases: Part of EU ]-----
    "GI", // Gibraltar
    "AX", // Åland Islands

    // -----[ Overseas Countries and Territories (OCT) ]-----
    "PM", // Saint Pierre and Miquelon
    "GL", // Greenland
    "BL", // Saint Bartelemey
    "SX", // Sint Maarten
    "AW", // Aruba
    "CW", // Curacao
    "WF", // Wallis and Futuna
    "PF", // French Polynesia
    "NC", // New Caledonia
    "TF", // French Southern Territories
    "AI", // Anguilla
    "BM", // Bermuda
    "IO", // British Indian Ocean Territory
    "VG", // Virgin Islands, British
    "KY", // Cayman Islands
    "FK", // Falkland Islands (Malvinas)
    "MS", // Montserrat
    "PN", // Pitcairn
    "SH", // Saint Helena
    "GS", // South Georgia and the South Sandwich Islands
    "TC", // Turks and Caicos Islands

    // -----[ Microstates ]-----
    "AD", // Andorra
    "LI", // Liechtenstein
    "MC", // Monaco
    "SM", // San Marino
    "VA", // Vatican City

    // -----[ Other ]-----
    "JE", // Jersey
    "GG", // Guernsey
];

Hi guys,

thanks @henrik for this and everyone that contribute.
Same list from @qmcree but in a yaml list format (with no indent):

- FI
- FR
- DE
- GR
- HU
- IE
- IT
- LV
- LT
- LU
- MT
- NL
- PL
- PT
- RO
- SK
- SI
- ES
- SE
- GB
- GF
- GP
- MQ
- ME
- YT
- RE
- MF
- GI
- AX
- PM
- GL
- BL
- SX
- AW
- CW
- WF
- PF
- NC
- TF
- AI
- BM
- IO
- VG
- KY
- FK
- MS
- PN
- SH
- GS
- TC
- AD
- LI
- MC
- SM
- VA
- JE
- GG

@plpepin
Copy link

plpepin commented Mar 24, 2021

A drop-down in Liquid

{%- capture cntriesList -%}
Austria:AT,Belgium:BE,Bulgaria:BG,Croatia:HR,Cyprus:CY,Czech Republic:CZ,Denmark:DK,Estonia:EE,Finland:FI,France:FR,Germany:DE,Greece:GR,Hungary:HU,Ireland:IE,Italy:IT,Latvia:LV,Lithuania:LT,Luxembourg:LU,Malta:MT,Netherlands:NL,Poland:PL,Portugal:PT,Romania:RO,San Marino:SM,Slovakia:SK,Slovenia:SI,Spain:ES,Sweden:SE,United Kingdom:GB,Vatican City:VA
{%- endcapture -%}

{% assign countries = cntriesList | split: ',' %}

-- select html tag open --
{% for country in countries %}
{% assign cntryName = country | split: ':' | first %}
{% assign cntryCode = country | split: ':' | last %}
-- option name="{{ cntryCode }}">{{ cntryName }} --
{% endfor %}
-- select html tag close --

@panoply
Copy link

panoply commented Sep 28, 2021

For those getting here are writing JavaScript/TypeScript. Leverage Set for validating EU member nations by country code, eg:

const EU = new Set([
  'AL',
  'AD',
  'AT',
  'AZ',
  'BY',
  'BE',
  'BA',
  'BG',
  'HR',
  'CY',
  'CZ',
  'DK',
  'EE',
  'FI',
  'FR',
  'GE',
  'DE',
  'GR',
  'HU',
  'IS',
  'IE',
  'IT',
  'KZ',
  'XK',
  'LV',
  'LI',
  'LT',
  'LU',
  'MK',
  'MT',
  'MD',
  'MC',
  'ME',
  'NL',
  'NO',
  'PL',
  'PT',
  'RO',
  'RU',
  'SM',
  'RS',
  'SK',
  'SI',
  'ES',
  'SE',
  'CH',
  'TR',
  'UA',
  'GB',
  'VA',
])

const isEU = (code: string): boolean => EU.has(code)

This is the cleanest way to do this. I have seen developers reach for iteration for matches, try not to do this, as a pre-populated Set will suffice nicely and comes at little cost. For some additional helper utils (which might of use to you all) we open sourced a couple little modules, for dealing with i18n aspects that somewhat pertain to this nexus:

Country code to currency code mappings:

Country code to country name (English) mappings:

Hope it helps! Happy coding.

@bradydan
Copy link

bradydan commented Oct 19, 2021

@bigghe @plpepin @panoply the UK (GB) is no longer in the EU, sadly. So your lists are not correct.

The list of EU countries is here courtesy of Eurostat, the "statistical office of the European Union"

Also, note that the European Commission does not always use ISO 3166-1 alpha-2 codes, including at the Eurostat link above. As explained on Wikipedia:

The European Commission generally uses ISO 3166-1 alpha-2 codes with two exceptions: EL (not GR) is used to represent Greece, and UK (not GB) is used to represent the United Kingdom.[10] This notwithstanding, the Official Journal of the European Communities specified that GR and GB be used to represent Greece and United Kingdom respectively.[11] For VAT administration purposes, the European Commission uses EL and GB for Greece and the United Kingdom respectively.

So, depending on your use case, you may need to amend and extend the list of standard ISO 3166-1 alpha-2 codes

@panoply
Copy link

panoply commented Oct 19, 2021

@bradydan is it official in UK already? I will have peek on the E.U governing sites. I am aware of the EL reference for Greece (I am Greek) however the vast majority of services feed GR when they are US based, might be worth adding EL in any sense. Wikipedia cannot be trusted nowadays, I will look on the gov counterparts and amend where necessary once I can confirm. Thanks for taking the time to leave your comment fam.

@VagishVela
Copy link

@bradydan The UK adopted GDPR into the law when they left the EU.

@DanKaplanSES
Copy link

I think this is an up to date 2022 list? https://www.defensorum.com/gdpr-countries-list/

@DanKaplanSES
Copy link

I asked and answered this stack overflow question to come up with this list which I believe is up to date for 2022: AT, BE, BG, HR, CY, CZ, DK, EE, FI, FR, DE, EL, HU, IE, IT, LV, LT, LU, MT, NL, PL, PT, RO, SK, SI, ES, SE, UK

@FredTheDino
Copy link

FredTheDino commented Dec 20, 2023

What a helpful thread! The list posted by Dan is almost right - UK is no longer part of the EU.

According to the UK government atleast: https://www.gov.uk/eu-eea
According to the canadian governement from 2013 (so needs modification): https://www23.statcan.gc.ca/imdb/p3VD.pl?Function=getVD&TVD=141329
According to the actual EU: https://european-union.europa.eu/easy-read_en

The alpha 2 code for Greece is GR no EL - which AFIK is not a valid Alpha2 code.
The correct list (with Alpha2 codes) would then be:

AT BE BG HR CY CZ DK EE FI FR DE GR HU IE IT LV LT LU MT NL PL PT RO SK SI ES SE

Cheers!

@bradydan
Copy link

This thread was originally about EU countries, them @mizterp changed the topic to GDPR countries and it (confusingly) became a mixture of both topics.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment