// Verbose String sObjectPrefix = '0Af'; Id sObjectId = Id.valueOf(sObjectPrefix.rightPad(15, '0')); SObjectType sot = sObjectId.getSObjectType(); System.debug(sot); // Single line (thanks to Adrian Larson on SO) System.debug(Id.valueOf('0Af'.rightPad(15, '0')).getSObjectType());