What this tool does
This converter maps ISO 3166-1 alpha-2 country codes to flag emojis and back. Type GB to get 🇬🇧, US to get 🇺🇸, or paste a row of flags to recover their codes. It is useful for building country pickers, localisation tables, social bios, and travel content.
How it works
There is no dedicated “flag” code point for each country. Instead, a flag emoji is a pair of Regional Indicator Symbols. Each letter A–Z has an indicator at 0x1F1E6 + (letter − A). To build the flag for a code like GB, the tool emits the indicator for G followed by the indicator for B; the renderer recognises the valid country code and draws the flag.
Decoding reverses the process: the tool walks the string by Unicode code point, and whenever it finds two consecutive Regional Indicator Symbols it converts each back to its letter and joins them into a two-letter code.
Tips and notes
- Only assigned ISO codes render as flags. An invalid pair such as
XXwill display as two boxed letters on most platforms. - Codes are caseless:
gb,GbandGBall produce 🇬🇧. - Sub-national flags (England 🏴, Scotland 🏴) are not alpha-2 codes — they use a separate tag-sequence encoding and are outside the scope of this two-letter converter.
- Each indicator is an astral code point occupying two UTF-16 units, so the decoder iterates by code point rather than by string index.