Back to The Times of Claw

How to Export All Your Data from Salesforce

Step-by-step guide to exporting everything from Salesforce: contacts, accounts, opportunities, custom objects, metadata, and activity history. Complete 2026 guide.

The Dench Team
The Dench Team
·9 min read
How to Export All Your Data from Salesforce

How to Export All Your Data from Salesforce

Exporting data from Salesforce is achievable for any admin — but it requires knowing where everything lives and using the right tools for each type of data. The web UI, Data Loader desktop app, and SFDX CLI each have different strengths, and a complete export typically requires all three.

This guide covers every type of Salesforce data and the best method for exporting each.

What You Need Before Starting#

Admin access: Super Admin or System Administrator profile. Standard profiles often don't have export permissions.

API access: Required for Data Loader and SFDX. API access is included in Enterprise, Unlimited, and Developer editions. Check your edition if you hit errors.

Time: Large Salesforce exports take time. The built-in Data Export can take 24-48 hours to generate for large orgs. Plan accordingly.

Storage: A complete Salesforce export for a large org can be many gigabytes, especially with attachments and files.

Method 1: Salesforce Built-In Data Export#

The simplest method — no additional tools required.

Steps#

  1. Click the gear icon (⚙️) > Setup
  2. Search for Data Export in the Quick Find box
  3. Click Data Export
  4. Click Export Now (or Schedule Export for recurring exports)
  5. Select which objects to include (select all)
  6. Choose your export options:
    • Include Images, Documents, and Attachments
    • Include Salesforce Files and Salesforce CRM Content document versions
    • Replace carriage returns with spaces (recommended for CSV compatibility)
  7. Click Start Export
  8. Salesforce emails you when the export is ready (can take minutes to 48 hours)
  9. Download the ZIP file containing CSVs for each object

What This Gives You#

The built-in export includes all standard objects (Account, Contact, Lead, Opportunity, Case, Task, Event, etc.) and all custom objects as separate CSV files. Each file includes all fields for that object.

Limitation: For very large orgs, the export may be split into multiple files. The ZIP can be very large if you include files and attachments.

Method 2: Salesforce Data Loader#

For more control — filter which records you export, choose specific fields, and handle large volumes more efficiently.

Install Data Loader#

Download from: https://developer.salesforce.com/tools/data-loader

Data Loader is a Java application. Requires Java 11+.

Basic Export Process#

  1. Open Data Loader
  2. Click Export
  3. Log in with your Salesforce credentials (use Security Token if MFA is required)
  4. Select the object to export (e.g., Contact)
  5. Choose the output file location
  6. Write your SOQL query to select fields

Sample SOQL for Contact export:

SELECT Id, FirstName, LastName, Email, Phone, Title,
       AccountId, Account.Name, Account.Website,
       LeadSource, OwnerId, Owner.Name,
       CreatedDate, LastModifiedDate, LastActivityDate,
       MailingCity, MailingState, MailingCountry
FROM Contact
WHERE IsDeleted = false
ORDER BY LastModifiedDate DESC

Sample SOQL for Opportunity export:

SELECT Id, Name, AccountId, Account.Name, 
       ContactId, Amount, CloseDate, StageName,
       Probability, LeadSource, Type,
       OwnerId, Owner.Name, Description,
       CreatedDate, LastModifiedDate
FROM Opportunity
WHERE IsDeleted = false
ORDER BY CloseDate DESC

Important: Include Record IDs#

Always include the Id field in your exports. You'll need Salesforce IDs to:

  • Re-establish relationships between exported objects
  • Look up records if you need to re-export with additional fields
  • Verify record counts after migration

Exporting All Fields Dynamically#

To get ALL fields without manually listing them:

  1. In Data Loader, click Extract
  2. Log in
  3. Select your object
  4. Click Next
  5. In the query editor, start typing: SELECT then click All Fields button (if available) or use this approach in SFDX instead

Method 3: SFDX CLI (Most Powerful)#

The Salesforce CLI is the most powerful export tool. Install it from developer.salesforce.com/tools/salesforcecli.

Setup#

# Install SFDX
npm install -g @salesforce/cli
 
# Authenticate to your org
sf org login web --alias my-org
 
# Verify connection
sf org display --target-org my-org

Query with SFDX#

# Export contacts to CSV
sf data query \
  --query "SELECT Id, FirstName, LastName, Email, AccountId FROM Contact WHERE IsDeleted = false" \
  --result-format csv \
  --target-org my-org \
  > contacts_export.csv
 
# Export large datasets with bulk API
sf data query \
  --query "SELECT Id, FirstName, LastName, Email FROM Contact" \
  --result-format csv \
  --bulk \
  --target-org my-org \
  > contacts_bulk.csv

Get All Field Names for an Object#

Before exporting, get the complete field list:

sf sobject describe --sobject Contact --target-org my-org | jq '.fields[].name'

Use this to build comprehensive SOQL queries.

Bulk Export Script#

For exporting all objects programmatically:

#!/bin/bash
OBJECTS=("Account" "Contact" "Lead" "Opportunity" "Task" "Event")
 
for OBJ in "${OBJECTS[@]}"; do
  echo "Exporting $OBJ..."
  sf data query \
    --query "SELECT FIELDS(ALL) FROM $OBJ WHERE IsDeleted = false LIMIT 200" \
    --result-format csv \
    --target-org my-org \
    > "${OBJ}_export.csv"
done

Note: FIELDS(ALL) is supported in the REST API but has a 200-record limit per query. For large exports, generate the field list dynamically and paginate.

Exporting Activity Data (Tasks and Events)#

Activity data is critical and often overlooked.

Tasks (Calls, Emails, To-Dos)#

SELECT Id, Subject, Description, ActivityDate, Status, Priority,
       OwnerId, Owner.Name, WhoId, Who.Name, WhatId, What.Name,
       CallType, CallDurationInSeconds, CallDisposition,
       CreatedDate, LastModifiedDate
FROM Task
WHERE IsDeleted = false
ORDER BY ActivityDate DESC

Events (Meetings, Appointments)#

SELECT Id, Subject, Description, StartDateTime, EndDateTime,
       OwnerId, Owner.Name, WhoId, Who.Name, WhatId, What.Name,
       Location, IsAllDayEvent, CreatedDate
FROM Event
WHERE IsDeleted = false
ORDER BY StartDateTime DESC

Email Messages (if using Salesforce Email)#

SELECT Id, Subject, TextBody, HtmlBody, FromAddress, ToAddress,
       ActivityId, RelatedToId, MessageDate
FROM EmailMessage
WHERE IsDeleted = false
ORDER BY MessageDate DESC

Exporting Notes and Attachments#

Classic Notes#

SELECT Id, Title, Body, ParentId, OwnerId, CreatedDate
FROM Note
WHERE IsDeleted = false

Enhanced Notes (ContentNote)#

SELECT Id, Title, Content, TextPreview, CreatedDate, LastModifiedDate
FROM ContentNote

Note: The Content field in ContentNote is base64-encoded. You'll need to decode it to get the text.

Files and Attachments#

For Salesforce Files (ContentDocument):

# Export file metadata
sf data query \
  --query "SELECT Id, Title, FileType, FileExtension, ContentSize, CreatedDate FROM ContentDocument" \
  --result-format csv \
  > files_metadata.csv
 
# For actual file content, use the REST API
curl -X GET "https://YOUR_INSTANCE.salesforce.com/services/data/v58.0/sobjects/ContentVersion/VERSION_ID/VersionData" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -o "downloaded_file.ext"

Exporting Custom Objects#

List all custom objects in your org:

sf data query \
  --query "SELECT DeveloperName, Label, IsCustomSetting FROM CustomObject ORDER BY DeveloperName" \
  --target-org my-org

For each custom object, export with:

-- Replace MyCustomObject__c with your actual object API name
SELECT Id, Name, FIELDS(CUSTOM)
FROM MyCustomObject__c
WHERE IsDeleted = false

Exporting Metadata (Schema Documentation)#

Salesforce metadata — field definitions, validation rules, workflow rules, permission sets — isn't "data" but is critical to document before migration.

Export Metadata Package#

# Create a package.xml to specify what to export
cat > package.xml << EOF
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
  <types>
    <members>*</members>
    <name>CustomObject</name>
  </types>
  <types>
    <members>*</members>
    <name>CustomField</name>
  </types>
  <types>
    <members>*</members>
    <name>WorkflowRule</name>
  </types>
  <version>58.0</version>
</Package>
EOF
 
# Retrieve metadata
sf project retrieve start --manifest package.xml --target-org my-org

This downloads XML files for all your custom objects, fields, and automation rules. Use these as reference documentation for recreating the schema elsewhere.

Exporting Reports and Dashboards#

Salesforce reports and dashboards are org-specific and can't be exported as portable files. Options:

  1. Export report data: Run each report, then use Export to get the underlying CSV data
  2. Screenshot dashboards: Visual reference for recreating in your destination tool
  3. Note report filters: Document the filters, groupings, and date ranges for each report

Handling Relationships in Exports#

Salesforce IDs are crucial for preserving relationships. When you export Contacts, you get AccountId (e.g., 0017d000000XXXXX). When you export Accounts, you get Id.

To re-establish relationships during import to another CRM:

  1. Export Accounts — note the Id column
  2. Export Contacts — the AccountId references Account Id
  3. During import: match Contact's AccountId to the corresponding Account by creating a lookup map

In practice, most destination CRMs let you match by a business key (like domain name or email) rather than Salesforce's internal ID. This is cleaner and more maintainable.

Opportunity Stage History#

The stage history — when each deal moved between stages — lives in OpportunityHistory and OpportunityFieldHistory:

SELECT OpportunityId, Opportunity.Name, StageName, Amount, 
       Probability, CloseDate, CreatedDate
FROM OpportunityHistory
ORDER BY CreatedDate DESC

This data is often overlooked but critical for understanding pipeline velocity and historical win rates.

Complete Export Checklist#

Standard Objects:

  • Account
  • Contact
  • Lead
  • Opportunity
  • OpportunityHistory (stage history)
  • Case (if Service Cloud)
  • Task (activities)
  • Event (activities)
  • EmailMessage (email history)
  • Note (classic notes)
  • ContentNote (enhanced notes)
  • ContentDocument (files)

Custom Objects:

  • List and export all active custom objects

Metadata (Documentation):

  • Field definitions for all objects
  • Validation rules
  • Workflow rules
  • Process Builder flows
  • Custom report types
  • User list and profiles

After the Export#

Organize your files: Create a folder structure: /salesforce-export/YYYY-MM-DD/ with subfolders for each object type.

Verify counts: Check that your export row counts match Salesforce's record counts. Go to Setup > Storage and compare record counts.

Archive securely: These exports contain sensitive business data. Store them with appropriate access controls.

Don't delete from Salesforce yet: Keep the Salesforce org accessible for 60-90 days after migration to resolve any issues.

Frequently Asked Questions#

How long does a Salesforce Data Export take?#

For the built-in Data Export: 24-48 hours for large orgs. For Data Loader or SFDX CLI queries: seconds to minutes per object depending on record volume.

Can standard users export from Salesforce?#

Standard user profiles typically don't have export permissions. This needs to be enabled by an admin in the user's profile settings, or they can be temporarily given System Administrator access for the export.

What happens to my data after I cancel Salesforce?#

Salesforce retains your data for 30 days after contract expiration. After that, it's deleted. Export everything before your subscription ends.

Is there a free Salesforce data export tool?#

Data Loader is free, available from Salesforce's developer tools page. The SFDX CLI is also free. The built-in Data Export is available to all paid accounts.

How do I export Salesforce data without a technical background?#

The built-in Data Export Service (Setup > Data Export) is the most accessible option. It requires admin access but no technical knowledge beyond following the wizard.

Ready to try DenchClaw? Install in one command: npx denchclaw. Full setup guide →

The Dench Team

Written by

The Dench Team

The team behind Dench.com, the future of AI CRM software.

Continue reading

DENCH

© 2026 DenchHQ · San Francisco, CA