How to Add AccountId to a Salesforce Contacts CSV
Prepare a Salesforce Contacts CSV by looking up Account record IDs from an Accounts export, while keeping missing and duplicate matches visible.
On this page
A Contact can display an Account name in an export, but an import relationship should be based on the Account record ID when you need a precise link. The practical preparation step is to take an Accounts export, look up the right record for every Contact, and append an AccountId column to the Contacts CSV.
The Salesforce Contact-to-Account Import Joiner performs that lookup locally and refuses to guess when a key maps to multiple Accounts.
Salesforce error: MALFORMED_ID
Salesforce reports MALFORMED_ID when an ID in the import CSV is malformed, uses unsupported characters, or is the wrong kind of record ID for the mapped field. If an AccountId row fails, verify the 15- or 18-character Account ID against the source org and confirm that the CSV column is mapped to the Contact account lookup. Salesforce documents this code in its MALFORMED_ID import guidance.
Why the ID column matters
Salesforce assigns records a 15- or 18-character identifier. Salesforce documents the 15-character form as case-sensitive and the 18-character form as case-safe for integrations. If your Accounts export already contains the form you use in Data Loader or another import workflow, keep it exactly as exported.
The joiner does not convert IDs. It copies the selected Account ID source into an output column named AccountId only for a unique match.
A practical preparation flow
- 01
Export Accounts
Include Id and the field you will use for matching, such as Name or a stable external account key.
- 02
Prepare Contacts
Make sure the Contacts CSV contains the corresponding match value. It can use a different column name.
- 03
Run the lookup
Select the Contact key, Account key, and Account ID source. The join runs in the browser.
- 04
Resolve exceptions
Unmatched and ambiguous rows keep AccountId blank. Review these before import instead of accepting an arbitrary duplicate.
- 05
Download the prepared CSV
The output keeps every Contact column and contains exactly one AccountId column ready for your mapping step.
Existing AccountId values
If the source Contacts CSV already has an AccountId column, a successful unique lookup replaces that cell with the Account ID from the Accounts export. For an unmatched or ambiguous row, the result is blank. This behavior is deliberate: retaining an old value while the current lookup says “unresolved” can hide a stale relationship.
Make a backup of your original export before bulk changes, and always review the unresolved rows.
Name matching versus external IDs
Names are readable, but they change and they may repeat. A stable external ID shared between Contacts and Accounts is a stronger lookup key when your data model provides one.
| Match field | Strength | Main risk | | --------------------- | ------------------------- | ------------------------------------- | | Account Name | Easy to inspect | Duplicate or renamed accounts | | External customer ID | Usually stable and unique | Must exist consistently in both files | | Salesforce Account ID | Exact Salesforce identity | 15-character IDs are case-sensitive |
If you use a Salesforce ID as the matching field itself, keep case-sensitive matching enabled. The optional case-insensitive mode is intended for business keys whose casing is not meaningful.
Validate before import
The tool confirms the join state, not the business meaning of every relationship. Before importing, verify that:
- every Contact that should have an Account has a non-empty
AccountId; - unresolved rows were intentionally left blank or have been corrected;
- the selected Account ID column came from the correct Salesforce org/export;
- your import mapping targets the Contact Account relationship field;
- the CSV structure is still valid.
Use Validate CSV for a structural pass. Salesforce also documents record ID formats and invalid ID errors in Data Loader.
FAQ
Should I convert every 15-character ID to 18 characters first?
Use the format expected by your Salesforce workflow. Salesforce documents the 18-character form as case-safe for integrations, but this joiner intentionally preserves the ID text from your export rather than changing it.
Does a matched account name guarantee the relationship is correct?
No. It only proves the selected key is unique within the provided Accounts CSV. Choose a key with business meaning and review the result before import.
See the transformation
Two tables meet on one exact lookup key.
Add matching customer details to each order while keeping missing or repeated matches visible.
Need to do this now?
Add AccountId to ContactsRelated tools
Open the tool this guide is about, or explore a related one.
- Join CSV files online freeJoin two CSV files on matching key columns, choose inner, left, or full results, and control duplicate lookup keys without uploading your data.
- CSV column mapper and renamerRename, reorder, and remove CSV columns before importing data into a CRM, store, database, or accounting system — without uploading your file.
- Validate CSV files online freeScan a CSV once for structural, encoding, header, delimiter, and whitespace problems without changing the file.