Data Loader · Field mapping

If you’ve ever hesitated before clicking Next on the mapping screen, this is the fix. Build every CSV with field API names in row 1 and Data Loader’s auto-match goes from “probably right” to “can’t be wrong.”

Row 1API names, the only row auto-match reads
X prefixto keep a column out of the map
0 guessesAPI names are unique on the object
4‑minute videoThe full walkthrough
On this page
  1. The problem
  2. Label vs API name
  3. Naming rules
  4. 1 · Row 1 = API names
  5. 2 · Run and verify
  6. Troubleshooting
  7. Gotchas and FAQ
Watch on YouTube ↗
The problem

Labels lie. API names can’t.

Data Loader’s auto-match is only as good as your CSV headers. Give it labels and it guesses. Give it API names and it can’t be wrong.

Auto-match is the one thing that makes the Data Loader mapping screen bearable (the UI has real 1989 energy). But a label isn’t unique: two fields can both be “Favorite Color”, a managed package like Financial Services Cloud can add its own copy of a standard field, and labels get renamed while API names stay put. Map by label and the load runs, errors are low, and later you find data in the wrong field.

Childhood photo of the author, around 1989
Me in 1989, around when the Data Loader UI was designed. Nice bangs.

Prefer to read? Everything in the video is written out below.

Label vs API name

Two identifiers, one guarantee.

The label is for people. The API name is for code, integrations and Data Loader, and Salesforce forces it to be unique on the object.

LabelAPI name
ExampleFavorite ColorFavorite_Color__c
Unique on the object?NoYes
Changes over time?OftenRarely, and not once code uses it
Used byUsersApex, merge fields, integrations, Data Loader
Salesforce picklist field showing its label next to its API name
Same field, two names. Data Loader wants the second one.
Two Salesforce fields with the same label Favorite Color but different API names
Two fields labelled Favorite Color. Only the API names tell them apart.
How Salesforce builds them

The naming rules.

Salesforce starts from the label and cleans it up.

  • Special characters are stripped. Question marks, dashes and so on don’t carry over
  • No leading numbers. “1st Favorite Color” becomes X1st_Favorite_Color__c
  • Spaces become underscores
  • Underscores have limits: none at the end, none back to back
  • Unique on the object, always. Custom ones end in __c
Salesforce adds an X to a field name when the label starts with a number
A label starting with a number gets an X.
Salesforce replaces spaces in a field label with underscores in the API name
Spaces become underscores.
Step 1

Put API names in row 1.

Data Loader only reads the first row when it auto-matches.

  1. Row 1: API names, nothing else. This is what auto-match reads.
  2. Row 2 (while you work): the labels, so a client or reviewer can read the file.
  3. Columns you don’t want loaded: put an X in front of the header (XNotes). Auto-match skips them, and anyone scanning the file can see they’re deliberately out.
CSV for Data Loader with API names in row 1 and labels in row 2
API names in row 1, labels in row 2 for humans.

Delete the labels row before you load. Data Loader treats every row after the header as a record, so a labels row left in gets loaded (or fails) as data.

Step 2

Run it and watch auto-match work.

The demo is an upsert on Contact, matched on a Legacy ID.

  1. Save the CSV. Open Data Loader and choose Upsert.
  2. Pick Contact and the file. Match on Legacy ID, an External ID field.
  3. Create or Edit a Map → Auto-Match Fields to Columns. With API-name headers, everything lines up.
  4. Choose an output folder and finish. 1 upsert, 0 errors.
  5. Open the record and check: Favorite Color = green, Favorite Color 2 = blue. Each value went to the field you meant.
Salesforce Data Loader upsert mapping auto-matched from API-name CSV headers
Auto-match with API-name headers. Nothing to fix.

Typing API names by hand gets old. The free tools in the API names post pull them for you.

Troubleshooting

When the mapping goes wrong.

SymptomCheck
Auto-match misses columnsRow 1 holds API names, with no typos or trailing spaces
Data in the wrong fieldYou mapped a label. Look for two fields with similar labels and pick by API name
Field missing from the mapping listField-level security, or Data Loader needs a fresh login after the field was created
Field won’t updateIt’s read-only or a formula, or the match key isn’t in Salesforce
Duplicate value on upsertThe match field isn’t unique in the file or the org

Other error codes are in the Data Loader errors post.

Gotchas

The questions people ask.

Why API names and not labels?
API names are unique and stable. Labels can repeat and change, which leads to data quietly going in the wrong field.
Can I keep labels in the file?
In a review copy, as row 2. Delete that row before the load.
How do I stop a column from mapping?
Prefix its header with X. Auto-match ignores it.
Fastest way to get API names?
Object Manager → Fields & Relationships, or a free browser tool. See the API names post.
How do I know it worked?
Zero errors is step one. Then open a few records and check the values landed in the right fields.
Data Migration Masterclass

Mapping is where migrations go right or wrong.

The Masterclass walks through the whole migration, including the field mapping workbook I use to get every object right before the first load.

Know someone who still maps Data Loader by label?

Share on LinkedIn
Doing this for a whole org, not just one object?

One CSV is a tutorial. Forty objects, 15 years of history and a go-live date is a project. That’s the part I do for a living.

See how I run migrations →