How to convert Salesforce record IDs from 15 char to 18 char?

When working in Salesforce, you may come across your record IDs often. Every Salesforce record during creation generates a globally unique identification value in its ID field. This record ID value will remain the same even if you delete and restore the record data.

When you update any field on a record, Salesforce will still recognize it based on the Id. The Id will always be a key data point of all automated processes and integrations.

Salesforce ID converter banner

There are two Record ID formats in Salesforce, 

  • 15-digit character ID
  • 18-digit character ID.

API versions after 2.5 exclusively use the 18-character format only. Look at this guide to learn how to convert a 15-character ID to 18 characters in Salesforce.

Salesforce ID 15 vs 18 difference

Parts of Salesforce ID

In an 18-digit Salesforce Id, the last three digits represent a checksum of the first 15 characters. The Id Field Type is a 62-base encoded string.

Each character can be one of the following 62 possible values:

  • Lowercase letter (a-z) – 26 values
  • Uppercase letter (A-Z) – 26 values
  • Numeric digit (0-9) – 10 values

 There is a combination of lower and upper-case letters in the 15-character id, and this determines what it means.

E.g. 20370000000015a is a different ID from 20370000000015A.

Algorithm to convert 15 char ID to 18 char ID

The algorithm to convert from a 15-character Id to an 18-character Id is: Divide the 15 char into three chunks of 5 chars each. A CASESAFEID function in the formula will perform the following algorithm.

  1. For each character, provide a value of 1 if uppercase, 0 for lowercase, or a number.
  2. Combine the bits from each chunk into a 5-bit integer. The most significant bit is on the right-hand side, and the least significant bit is on the left.
  3. Build an array that contains the sequence of capital letters A-Z and 0-5 (26 + 6 = 32 possible values).
  4. Use the integer from each chunk to select a character from the array.
  5. Append the resulting 3 characters to the end of the 15-char id.

Techniques to convert 15 char ID to 18 char ID

1. Salesforce Formula Field

Salesforce recommends creating a formula field to obtain the 18-digit Id. And the formula to convert Salesforce ids is CASESAFEID(id).

However, there are a few things to consider:

  • Create the formula field on all Standard and Custom objects as a custom field.
  • Ensure the field appears on all required report types and accept all the permissions.
  • Train the users to utilize the new field and alter their existing reports to incorporate it.

a. Salesforce Lightning:

  • Go to Setup > Object Manager Tab > Click the name of the object where you want to create the 18-digit ID
  • Go to Fields & Relationships > Click New Button in the upper right-hand corner of the page

b. Salesforce Classic:

  • Go to Setup > Under App Setup, click Customize
  • Click on the object name where you want to create the 18-digit ID
  • Click on Fields
  • In the Custom Fields & Relationships section of the page, click “New”.

Then follow the steps below:

  1. Select Formula Data Type > click Next
  2. Name your field

Example: Account ID (18)

  1. Select the formula return type as Text
  2. Click on the Advanced Formula tab > click Insert Field button
  3. Select the ID field based on your need.
  4. Place CASESAFEID before the ID field. Add the text “Id” in parenthesis and click Next.

Salesforce formula field
  1. Set field level security for the formula field and click Next.
  2. Decide whether this field should appear on your page layout. Click Save to apply these changes.

2. Online Tool

Nowadays, there are a lot of tools that can convert 15-character IDs to 18-character IDs. Some online tools allow you to download the converted ids in text files.

Below are some of the online tool converters available.

3. Build Your Own Code

Javascript Browser Bookmarklet is another recommendation by Salesforce to convert IDs manually. 

Add this Javascript as a bookmarklet in your browser, and you’ll be able to convert IDs with just the flick of your finger. But this might not work in Microsoft Edge.

  1. Create a new bookmark and name it.
  2. Add the code below the URL.
  3. Save the bookmark.



var input=prompt(‘Enter 15-character ID’);

var output;

                   if(input.length == 15){

                                      var addon=””;

                                      for(var block=0;block<3; block++)


                                          var loop=0;

                                                  for(var position=0;position<5;position++){

                                                      var current=input.charAt(block*5+position);

                                                          if(current>=”A” && current<=”Z”)








                                      alert(“Error : “+input+” isn’t 15 characters (“+input.length+”)”);



prompt(’18-character ID:’,output);


To use the converter:

  1. Click the bookmark
  2. Enter the 15-character ID and click “OK
  3. Copy out the resulting 18-character ID

4. Convert Ids in Excel Document

While online tools are a quick solution for converting a lot of IDs in one go, they don’t provide the kind of accuracy when working with hundreds or even thousands of records in CSV and Excel files. Copy and paste work becomes much more time-consuming as you have to copy and paste each ID individually.

When you have a lot of rows in Excel that need to convert the ID from 15 to 18 characters, use the Excel formula.

Points to remember:

  1. Add the following formula into a formula field of type Text.
  2. Change A2 with the excel cell of 15 characters ID.

You can use the below formula in Excel to convert a 15-digit ID to an 18-digit ID.


















It is important to be aware of all possible options to ensure choosing the best one every time while converting Salesforce’s 15-digit record ID to an 18-digit record ID. Always ensure the safeness of the online converter tools. Those providing the best and correct results make work much easier than ever.

Subscribe to blogs

Get our latest blogs directly to your inbox.


    This website stores cookies on your computer. Privacy Policy