Whether you are planning a massive data migration, cleaning up technical debt, or preparing for a compliance audit, you need a clear map of your Salesforce architecture. Manually clicking through the Object Manager to document hundreds of fields is a mind-numbing and time-consuming process. Thankfully, you can easily export your entire schema directly into a CSV spreadsheet to create a comprehensive data dictionary.
Key Points Summary
- Creating a data dictionary is essential for org cleanups, system audits, and integration mapping.
- The modern, fastest way to extract field data is by querying the
FieldDefinitionobject using the Tooling API. - Free browser extensions like Salesforce Inspector Reloaded make exporting schema to Excel or CSV a one-click process.
- Developers can leverage the updated Salesforce CLI (
sfcommands) to pull object metadata automatically.
Why Create an Offline Salesforce Data Dictionary?
Having a complete spreadsheet that maps out your Salesforce schema is incredibly valuable for several reasons:
- Data Migration & Integrations: Easily map source data to Salesforce target fields when using tools like Data Loader, MuleSoft, or custom APIs.
- System Auditing & Cleanup: Spot unused, redundant, or orphaned custom fields that are cluttering your org and holding you back from clean deployments.
- Compliance & Governance: Maintain a snapshot of where sensitive data (like GDPR, HIPAA, or PII) lives across your objects.
- Stakeholder Documentation: Quickly hand over an up-to-date schema reference to external consultants, business analysts, or new developers.
Method 1: The Modern Way (SOQL & Tooling API)
Instead of writing complex Apex loops, you can now query Salesforce's metadata directly using the Tooling API. You can run this simple query in the Developer Console Query Editor (check the "Use Tooling API" box at the bottom) or via Salesforce Inspector.
Run this query to instantly extract all fields on the Account object. You can then copy the results straight into a spreadsheet.
SELECT QualifiedApiName, DeveloperName, DataType, Length
FROM FieldDefinition
WHERE EntityDefinition.QualifiedApiName = 'Account'
Method 2: Use Modern Free Browser Tools
For admins who want a purely point-and-click experience across the entire org, dedicated schema tools are the best route. They handle the heavy lifting behind the scenes.
- Salesforce Inspector Reloaded: This free Chrome extension is the holy grail for Salesforce pros. Navigate to its "Data Export" tab and run the query above, or use its built-in schema explorer to copy field definitions straight to Excel.
- Salesforce Schema Builder: While native to Salesforce and great for visual mapping, it doesn't export to CSV easily. Use it for visualizing relationships, but stick to data tools for spreadsheet exports.
Method 3: Export Object Schema via Anonymous Apex
If you prefer a built-in programmatic solution, you can run a script in the Developer Console to extract object and field metadata directly to your debug logs.
// Define the object you want to export
String objectName = 'Account';
Map<String, Schema.SObjectField> fieldMap = Schema.getGlobalDescribe().get(objectName).getDescribe().fields.getMap();
System.debug('Field Label,API Name,Data Type,Length');
for (Schema.SObjectField field : fieldMap.values()) {
Schema.DescribeFieldResult fieldDescribe = field.getDescribe();
System.debug(
fieldDescribe.getLabel() + ',' +
fieldDescribe.getName() + ',' +
fieldDescribe.getType() + ',' +
fieldDescribe.getLength()
);
}
Once the script finishes, check the Debug Only box in your log panel, copy the comma-separated output, and paste it into a .csv file.
Method 4: The Salesforce CLI (sf)
If you are a developer using VS Code, you can use the modern Salesforce CLI (sf) to pull object definitions directly into your terminal. This is perfect for automating documentation.
sf sobject describe --sobject Account
This command returns a highly detailed JSON structure of the object, which you can easily parse into a CSV using a simple Python or Node.js script.
- Governor Limit Exhaustion in Apex: Running
Schema.getGlobalDescribe()across all objects at the same time in Apex will likely hit CPU time limits or heap size errors. Export objects one by one, or use the SOQL Tooling API method. - Field-Level Security (FLS) Hidden Fields: API extensions and SOQL queries respect the logged-in user's profile permissions. If your profile doesn't have Read access to a field, it won't show up in your export! Always run these exports logged in as a System Administrator.
Frequently Asked Questions (FAQ)
A: Doing this via Apex or SOQL usually hits system limits because enterprise orgs have thousands of fields. Your best bet for a full-org export is using third-party AppExchange apps (like Config Workbook) or writing a script using the Salesforce CLI that iterates through objects one by one.
A: No. The weekly Data Export service in Setup only exports the actual record data (the rows), not the metadata or schema definitions (the columns).
A: Yes! If you use the Anonymous Apex method, you can add fieldDescribe.getPicklistValues() to your debug loop. Just be aware that fields with hundreds of picklist values can make your CSV output messy.
- Core Concept: Extracting Object & Field Metadata to CSV/Excel.
- Best Use Cases: Creating a Data Dictionary, Org Audits, API Integration Mapping.
- Top Recommended Tools: SOQL Tooling API, Salesforce Inspector Reloaded, Salesforce CLI (
sf). - Data Points Captured: Field Labels, API Names, Data Types, Field Lengths, and Custom/Standard status.