# Normalize Countries, Postal Codes & Currencies - ISO Codes (`that_red_bird/country-postal-normalizer`) Actor

Messy country names, postal codes and currencies to clean ISO codes. Country in any language to ISO 3166, postal codes validated and reformatted per country (lost leading zeros restored), currencies to ISO 4217. Offline, built for Google Maps and lead datasets.

- **URL**: https://apify.com/that_red_bird/country-postal-normalizer.md
- **Developed by:** [mohamed alaya](https://apify.com/that_red_bird) (community)
- **Categories:** Lead generation, Business, Automation
- **Security:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$0.30 / 1,000 row normalizeds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Normalize Countries, Postal Codes & Currencies - ISO Codes

Turns the messy country, postal-code and currency columns of a scraped dataset into clean ISO codes: "Deutschland" and "D-10115" and "euros" become `DE`, `10115` and `EUR`.
Built for people who merge Google Maps, lead or e-commerce datasets from many countries and need one consistent format before loading a CRM or warehouse.

### Quick start

1. Run your scraper, then start this Actor and pick its dataset in **Dataset(s) to normalize**.
2. Columns named like `country`, `postalCode` / `zip` / `postcode` and `currency` are detected automatically (or name them in the field settings).
3. Download the result as JSON, CSV or Excel. Run with empty input to see a demo of 9 messy rows.

### Input examples

**1. Dataset from a scraper**

```json
{ "datasets": ["<pick with the dataset picker>"] }
```

**2. Pasted rows**

```json
{ "rows": [{ "country": "Tunisie", "postalCode": "1000", "currency": "dinar tunisien" }, { "country": "usa", "postalCode": "2134", "currency": "$" }] }
```

**3. Rows with only an address, with a default country and place lookup**

```json
{ "rows": [{ "address": "5 Main St, Austin, TX 78701, United States", "postcode": "78701" }], "defaultCountry": "US", "lookupPlaces": true }
```

### Input guide

| Field | What it does |
|---|---|
| `datasets` | Pick one or more datasets (the picker gives the Actor read permission). |
| `rows` / `rowsCsv` | Paste JSON rows, a JSON array or a CSV with a header row. |
| `countryField`, `postalField`, `currencyField`, `addressField` | Column names, empty = auto-detect. |
| `defaultCountry` | Country assumed for rows that have none. |
| `lookupPlaces` | Add place name, region and coordinates for valid postal codes (zippopotam.us, about 60 countries). |
| `keepAllFields`, `maxRows` | Keep original columns / safety limit. |

### Output

Your original columns are kept and these are added (only for the columns that exist):

| Field | Meaning |
|---|---|
| `countryIso2`, `countryIso3`, `countryNumeric`, `countryName` | ISO 3166 codes and the English name. |
| `countryMatch`, `countrySource` | How it was found: `code`, `name` (any of 78 languages, plus aliases like UK, Holland, Czechia), `fuzzy` (one or two typos), `address` (from the end of an address), `default`. |
| `postalCode`, `postalValid`, `postalNote` | Cleaned postal code, `true`/`false` (or `null` when the country has no rule), and what was fixed (`zero-padded`, `removed-country-prefix`, `reformatted`). |
| `currencyCode`, `currencyNumeric`, `currencyName`, `currencyMatch` | ISO 4217 from a code, symbol (`€`, `zł`, `د.ت`), name ("dinar tunisien", "euros") or `$` / `kr` / `Rs.` disambiguated by the row's country (`symbol-country`) or assumed (`symbol-assumed`). |
| `countryCurrency` | Official currency of the row's country. |
| `normalizationFixes` | Plain list of what was corrected. |
| plus `placeName`, `region`, `latitude`, `longitude` | Only with `lookupPlaces`. |

Sample row:

```json
{ "country": "Deutschland", "postalCode": "D-10115", "currency": "euros", "countryIso2": "DE", "countryIso3": "DEU", "countryName": "Germany", "countryMatch": "name", "postalCode": "10115", "postalValid": true, "currencyCode": "EUR", "countryCurrency": "EUR" }
```

### Use it with

Google Maps scraper or lead finder -> **this Actor** -> your CRM or warehouse. This Actor does not split street addresses; it standardises the country, postal and currency columns for every country.

### FAQ

**What is the difference to an address parser?** This Actor does not split street addresses. It standardises three columns.

**Does it call a web service?** Only if you turn on `lookupPlaces` (zippopotam.us). Everything else is offline.

**Why was my postal code "zero-padded"?** Spreadsheets drop leading zeros (`02134` becomes `2134`). When the padded code is valid for the country and the original is not, it is restored.

### Honest limits

- A bare `$` without a country is assumed to be USD; `kr`, `Rs.` and `pesos` need a country, otherwise the currency stays empty or assumed. `¥` is read as yen unless the country is China.
- Postal rules come from a public rules library; `postalValid: null` means the country has no rule, `false` means the code does not match the national format (it does not prove the code exists).
- Country spelling correction handles one or two typos in names of six letters or more; short or very garbled names stay unrecognised rather than guessed.
- Country from an address only looks at the last two comma-separated parts.

### Price

Pay per event: **$0.0003 per row normalized** (rows where at least a country, a valid postal code or a currency was resolved; unresolved rows are free). 100,000 rows = $30.

# Actor input Schema

## `datasets` (type: `array`):

Pick the dataset of any Google Maps, lead or e-commerce scraper run. Use the picker rather than typing an ID: it gives this Actor permission to read your dataset. Leave empty to use the pasted rows below, or the built-in demo list.

## `rows` (type: `array`):

Optional. Paste rows as JSON objects, e.g. {"country":"Deutschland","postalCode":"D-10115","currency":"euros"}. Plain strings are treated as a country. Other fields are kept in the output.

## `rowsCsv` (type: `string`):

Optional. Paste a CSV (first row = column names) or a JSON array. Columns named country, postalCode (or zip, postcode) and currency are detected automatically.

## `countryField` (type: `string`):

Name of the column with the country. Leave empty to auto-detect (country, countryCode, countryName, country_code and similar).

## `postalField` (type: `string`):

Name of the column with the postal code. Leave empty to auto-detect (postalCode, postcode, zip, zipCode, plz and similar).

## `currencyField` (type: `string`):

Name of the column with the currency (symbol, name or code). Leave empty to auto-detect (currency, currencyCode, priceCurrency and similar).

## `addressField` (type: `string`):

When a row has no usable country, the country is read from the end of this address column (for example '... 1000 Tunis, Tunisia'). Leave empty to auto-detect an address column.

## `defaultCountry` (type: `string`):

Country (name or ISO code) assumed for rows without any country information, for example US or Tunisia. Postal code rules and ambiguous currency symbols need a country. Leave empty to leave such rows without a country.

## `lookupPlaces` (type: `boolean`):

For valid postal codes, also add place name, region and coordinates using the free zippopotam.us service. It covers about 60 countries and makes one web request per distinct postal code, so large runs are slower. Off by default.

## `keepAllFields` (type: `boolean`):

When on, every field of the input row is copied to the output next to the normalized columns. Turn off to output only the new columns.

## `maxRows` (type: `integer`):

Safety limit on the number of rows processed in one run.

## Actor input object example

```json
{
  "rows": [],
  "rowsCsv": "",
  "countryField": "",
  "postalField": "",
  "currencyField": "",
  "addressField": "",
  "defaultCountry": "",
  "lookupPlaces": false,
  "keepAllFields": true,
  "maxRows": 100000
}
```

# Actor output Schema

## `results` (type: `string`):

No description

## `downloadCsv` (type: `string`):

No description

## `summary` (type: `string`):

No description

## `count` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "rows": [],
    "rowsCsv": "",
    "countryField": "",
    "postalField": "",
    "currencyField": "",
    "addressField": "",
    "defaultCountry": "",
    "maxRows": 100000
};

// Run the Actor and wait for it to finish
const run = await client.actor("that_red_bird/country-postal-normalizer").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "rows": [],
    "rowsCsv": "",
    "countryField": "",
    "postalField": "",
    "currencyField": "",
    "addressField": "",
    "defaultCountry": "",
    "maxRows": 100000,
}

# Run the Actor and wait for it to finish
run = client.actor("that_red_bird/country-postal-normalizer").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "rows": [],
  "rowsCsv": "",
  "countryField": "",
  "postalField": "",
  "currencyField": "",
  "addressField": "",
  "defaultCountry": "",
  "maxRows": 100000
}' |
apify call that_red_bird/country-postal-normalizer --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,that_red_bird/country-postal-normalizer"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/Bf5OMaCHAHcI7arXc/builds/VDHTTDnJSjoff7lHs/openapi.json
