I have a 15 digit Sfdc ID, but I do not know which object it belongs to.

How can I find out which objects it belongs to and the convert it to 18 digits - all using SOQL?

P.S. I was annoyed at having to do this manually every single time, so I created a small app that detects 15 digits SFDC IDs and then automatically up converts them to 18 digits.

Video: https://www.youtube.com/watch?v=1xwd9WkcG10

Github: https://github.com/rgelb/SfdcIdUpConverter

Download: https://github.com/rgelb/SfdcIdUpConverter/releases/download/1.2/SfdcIdUpConverterSetup.exe

P.S. The code no longer works with the latest rev of Salesforce. I am not planning to make any updates as I no longer work with Salesforce. If anyone wants to fork the GitHub repo, it might live on.

  • 1
    You can directly query the id of an sObject using the 15 char id value, and get the 18 char value returned. [SELECT Id FROM Account WHERE Id = '006V000000NT4kj'] will return the value '006V000000NT4kjIOU'. Commented Sep 29, 2015 at 13:26
  • Have a read of What are Salesforce ID's composed of?. The 15 and 18 character ID's can be used interchangeably in SOQL. Commented Sep 29, 2015 at 22:22

2 Answers 2


To convert it to 18 digits you can simply set it to an Id type variable:

Id someId = '001J000001eun1Q';

Which will automatically convert it for you:

system.debug(someId); // 001J000001eun1QIAQ

Then you can simply call the getSObjectType() method on the Id variable which will return the object name:

Schema.SObjectType objectType = someId.getSObjectType();
system.debug(objectType); // Account
  • But thats nit soql :)
    – zokito
    Commented Sep 29, 2015 at 6:25
  • You can't do that using SOQL, you have to use APEX. Commented Sep 29, 2015 at 6:27
  • That's also correct
    – zokito
    Commented Sep 29, 2015 at 6:28
  • Didn't get the answer I would have liked...but just the system.debug trick is worth millions! Commented Sep 29, 2015 at 16:45

I know this is an old post, but just in case it is useful to someone, if you want to do ad-hoc conversions of Id's, rather than programatically, then this Chrome extension makes it easy: https://chrome.google.com/webstore/detail/sf-15-to-18/cogllpmaoflgaekieefhmglbpgdgmoeg

FYI - I'm the developer. Please use the feedback form on the app if you'd like to suggest any improvements or additional functionality.


  • Your extension works perfectly. I would like to understand the logic behind conversion of 15 digit to 18 digit. We need to build this conversion process in a c# application Commented Aug 11, 2021 at 20:31
  • This page explains it quite well: gammone.com/en/programming/…
    – cyberspy
    Commented Oct 21, 2021 at 8:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .