Back to column formats
Column formattingSharePoint Online

Country Flag

This sample demonstrates displaying the flag of the country selected in the single selection SharePoint choice column.

Country Flag formatting preview
Sample preview · View original image

Copy. Apply. Make it yours.

Get this format

1 definition

Review the requirements below, then paste this JSON into the matching formatting panel. Show me where.

Use your list's internal column names and replace any tenant-specific URLs or flow IDs. Formatting is presentation, not a way to secure data.

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

From the contributor

How to use this sample

Summary

This sample demonstrates displaying the flag of the country selected in the single selection SharePoint choice column.

screenshot of the sample

The country flag is shown using the FlagCDN - CDN & API of flags web site API. So, allow flagcdn.com domain in HTML Field Security settings of your SharePoint site by following this Microsoft official documentation: Allow or restrict the ability to embed content on SharePoint pages.

You can find the list of countries used in this JSON sample at: Countries

Add list of countries in the choice column settings like:

screenshot of the edit column

View requirements

  • This format can be applied to any text based column but a single selection choice column is the intent

Sample

Solution Author(s)
text-country-flag.json Ganesh Sanap

Version history

Version Date Comments
1.0 August 28, 2023 Initial release
1.1 October 19, 2025 Renamed from choice-country-flag to text-country-flag

Disclaimer

THIS CODE IS PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.