What are Salesforce ID’s composed of?
The Id Field Type is a base-62 encoded string.
Each character can be one of 62 possible values:
- a lowercase letter (a-z) – 26 values
- an uppercase letter (A-Z) – 26 values
- a numeric digit (0-9) – 10 values
- As there is a combination of lower and upper case letters the casing of the 15 character Id has significance. E.g. 50130000000014 c is a different ID from 50130000000014C.
Within a 15 character Id the breakdown is:
First 3 characters – Key Prefix As per Jon’s answer, the first 3 characters are the key prefix that identify the object type. There are a few exceptions to this where multiple objects all share the same key prefix! There are a number of fixed key prefixes that are common across all of Salesforce. Custom objects get a unique key prefix per Org. Custom objects in managed packages can have a different key prefix in each installed org.
The 4th Character – instance/pod identifier
5th Character – instance/pod identifier – extended
6th character – Reserved. Will be 0 until such time that Salesforce has a need for it.
Remaining 9 characters – basically a really big number. Like 62^9 big or 238,328! That’s a lot of servers!
To this you can add an optional 3 character suffix that will make the Id unique case-insensitive. This is useful when working with programs that can’t maintain the case of the ID (E.g. Excel VLookup).