Salesforce ID converter: 15 to 18 character, and back
Quick answer
A 15-character Salesforce ID is case-sensitive; the 18-character version adds a 3-character suffix that encodes the case, so it works in case-insensitive tools. Paste IDs below to convert 15 to 18 or 18 to 15, in bulk, and to see which object each ID belongs to from its three-character prefix.
Convert Salesforce IDs
The converter needs JavaScript. The explanation, worked examples and prefix table below work without it.
Paste IDs above to convert them.
| Input | 15-character | 18-character | Object | Status |
|---|
How the 15 to 18 character conversion works
Salesforce IDs use digits, lowercase letters and uppercase letters, and the 15-character form is case-sensitive:
000000000000Abc and 000000000000aBC are different records. Case-insensitive tools such as
Excel treat them as the same, so the API returns an 18-character ID with a 3-character suffix that records the case
of the first 15 characters.
- Split the 15 characters into three groups of five.
- For each group, build a number from five bits. A character at position 0, 1, 2, 3 or 4 adds 1, 2, 4, 8 or 16 if it is an uppercase letter A to Z, and adds nothing otherwise.
- Turn each number (0 to 31) into one character: 0 to 25 become
AtoZ, and 26 to 31 become0to5. - Append the three characters to the original 15-character ID.
To go from 18 back to 15 characters, drop the last three. Salesforce also states that changing the case of an 18-character ID makes the suffix wrong, and Salesforce then returns an error.
Worked examples
These conversions are generated by the same code the converter uses. The two Abc IDs differ only by case, and so do their suffixes.
| 15-character ID | Suffix | 18-character ID |
|---|---|---|
| 001D000000IqhSL | IAZ | 001D000000IqhSLIAZ |
| 000000000000Abc | AAE | 000000000000AbcAAE |
| 000000000000aBC | AAY | 000000000000aBCAAY |
| 005000000000001 | AAA | 005000000000001AAA |
Get the 18-character ID in Apex and formulas
// Apex: an Id converts to its 18-character form as a String
Id accountId = '001D000000IqhSL';
String id18 = String.valueOf(accountId);
// Formula field (Text): 18-character version of a record ID
CASESAFEID(Id)
SOQL accepts either form in a WHERE Id = filter, and the Id field in query results is always
the 18-character form. When you match IDs between Excel exports, a database or another tool, convert both sides to
18 characters first.
Salesforce ID prefixes by object
The first three characters of a record ID, the key prefix, identify the object. This table lists common standard
objects. Prefixes are case-sensitive: 00e is a Profile and 00E is a User Role. Custom objects
get a prefix specific to your org, and a prefix is not guaranteed to be the same in every org, so confirm in yours:
SELECT QualifiedApiName, KeyPrefix FROM EntityDefinition WHERE KeyPrefix != null
// or in Apex:
Account.SObjectType.getDescribe().getKeyPrefix() 32 prefixes
| Prefix | Object | API name |
|---|---|---|
001 | Account | Account |
003 | Contact | Contact |
005 | User | User |
006 | Opportunity | Opportunity |
007 | Activity | Activity |
00Q | Lead | Lead |
500 | Case | Case |
701 | Campaign | Campaign |
00D | Organization | Organization |
00T | Task | Task |
00U | Event | Event |
012 | Record Type | RecordType |
00e | Profile | Profile |
0PS | Permission Set | PermissionSet |
00G | Group | Group |
00E | User Role | UserRole |
01p | Apex Class | ApexClass |
01q | Apex Trigger | ApexTrigger |
015 | Document | Document |
00P | Attachment | Attachment |
068 | Content Version | ContentVersion |
069 | Content Document | ContentDocument |
00X | Email Template | EmailTemplate |
00O | Report | Report |
01Z | Dashboard | Dashboard |
01t | Product | Product2 |
01s | Price Book | Pricebook2 |
00k | Opportunity Product | OpportunityLineItem |
02i | Asset | Asset |
800 | Contract | Contract |
801 | Order | Order |
0D5 | Feed Item | FeedItem |
Frequently asked questions
What is the difference between a 15-character and an 18-character Salesforce ID?
The 15-character ID is case-sensitive. The 18-character ID is the same ID plus a 3-character suffix that encodes which of the first 15 characters are uppercase, which makes it safe to compare in case-insensitive tools such as Excel or Microsoft Access.
How do I convert a 15-character Salesforce ID to 18 characters?
Paste it into the converter above. To do it yourself, split the ID into three groups of five characters, set a bit for each uppercase letter in a group (first character is worth 1, then 2, 4, 8 and 16), and map each group total from 0 to 31 to the characters A to Z and 0 to 5. Append the three characters to the original ID.
How do I convert an 18-character Salesforce ID to 15 characters?
Remove the last three characters. Salesforce documents truncation as the way to get the 15-character version of an 18-character ID, although Salesforce recommends using the 18-character ID.
Does Salesforce accept both ID formats?
Yes. Salesforce accepts both 15 and 18-character IDs in the user interface, Apex and queries, and all API calls return the 18-character form. Use 18-character IDs when creating, editing or deleting data through the API.
How do I get the 18-character ID in Apex, SOQL or a formula?
In Apex, converting an Id to a String with String.valueOf(recordId) returns the 18-character form. In a formula field, the CASESAFEID function converts a 15-character ID to the 18-character version. Queries return the 18-character ID in the Id field.
Why does the converter say "checksum mismatch"?
The last three characters of an 18-character ID must match the case of the first 15. If the ID was lowercased, uppercased or retyped, the suffix no longer matches, and Salesforce rejects the changed ID. The tool shows the correct 18-character form for the first 15 characters, but if the case was lost the original ID cannot be recovered from the text alone.
Does the converter upload my IDs?
No. The conversion runs in your browser, and the IDs you paste are not sent to SFDX Talk or anyone else.
Related guides
More tools
SFDX Talk is unofficial documentation. It is not affiliated with, endorsed by, or sponsored by Salesforce, Inc. Salesforce changes its platform every release, so confirm against the official page before relying on a value.