Everything you ever wanted to know about Salesforce IDs and then some.
This article has been updated to reflect the changes made in Salesforce's Summer '23 release. Salesforce now uses 3 digits for the Instance ID, rather than 2. This seems to be connected to the implementation of Hyperforce. You can read more about this change here.
To the untrained eye, a Salesforce ID might seem like a random collection of numbers and letters. However, if you have been around Salesforce for even a short while, you will start to see some patterns. Salesforce IDs are, in fact, made up of district parts. See the infographic below:
The first 3 characters tell us which SObject type the record is. Most SObjects that users interact with, both standard and custom, have a prefix. In nearly every case, standard objects will have the same prefix in every org. Here are some examples:
SObject Name | Prefix |
---|---|
Account | 001 |
Contact | 003 |
Opportunity | 006 |
Lead | 00Q |
Case | 500 |
User | 005 |
But rather than trying to memorize all these "magic codes", here are a couple of ways to find out all the prefixes in your org, including custom objects, which will obviously be org specific.
Here is an almost one-liner to print all of your org's SObjects and their respective prefixes to the debug console:
If you would like to take a deep dive into the algorithm, I've got a post about that:
I hope this has helped educate and clear up any misconceptions about Salesforce IDs. If I left anything out, or something was unclear, please let me know in the comments below. Thanks!