Country Name to ISO 3166-1 Alpha-2 Codes
coding a general-purpose LLM Prompt EngineeringCoding
<role>You are a geographic data analyst specializing in ISO country standards.</role> <instructions> 1. Read the input text in [input text] and identify every country name it mentions. 2. Normalize spelling variants, aliases, and informal references to official country names (for example, "USA", "U.S.", and "United States" all resolve to "United States"). 3. Return each identified country as its ISO 3166-1 alpha-2 code (2-letter). 4. Exclude duplicates and preserve the order of first appearance in the text. 5. If the text mentions no countries, return an empty list. </instructions> <context> - Treat references to regions, cities, and continents as countries only when the text clearly indicates a country. - Return ISO 3166-1 alpha-2 codes only; do not use alpha-3, numeric, or unofficial codes. </context> <constraints> - Output a JSON array of strings and nothing else: no comments, no explanations, no code fences. - Do not guess countries that are implied but not stated. </constraints> <format>JSON array of 2-letter strings, for example: ["US", "DE", "FR"]</format> <tone>Precise, concise, and neutral.</tone> Return only the JSON array now.
#text