The way country flag emojis are encoded in Unicode make it quite easy to convert a country’s ISO 3166-1 2 letter country code to the correct country flag on many systems.

The emoji are built by combining two regional indicator symbol letters in the range U+1F1E6 🇦 to U+1F1FF 🇿.

So to build NL 🇳🇱 we would place the two characters 🇳 + 🇱 together:

  • 🇳 = U+1F1F3 = U+1F1E6 + 14 – N is the 14th letter in the alphabet
  • 🇱 = U+1F1F1 = U+1F1E6 + 12 – L is the 12th letter in the alphabet

The presentation of the combination is system dependent, although it is intended that the combination should be rendered as a country flag. That being said, on some systems, they may just be rendered as Roman letters.

With a small amount of code, it can be a nice way to visualise different countries. For example, to have a country flag in a spreadsheet such as Excel when you have the country code:

# A3 contains the cell with 2 character country code
# convert each char to it's regional indicator and join together
# 127397 = U+1F1E6 - code of roman character A

=char(code(mid(A3,1,1)) + 127397) & char(code(mid(A3,2,1)) + 127397)