15 vs 18 Digit Salesforce ID: Convert 15 to 18 (and Back) in Apex, Formulas and Excel

Export Account IDs from a report, VLOOKUP them against a Data Loader file in Excel, and you can get a match on the wrong account. The report gives 15-character IDs that depend on letter case, and Excel ignores case. The 18-character ID exists to stop exactly that.

We built the fix four ways in a Winter ’27 Developer Edition org: a tested Apex converter, a CASESAFEID(Id) formula field, the checksum by hand, and an Excel formula we checked against the platform output. By the end you can convert any 15 to 18 digit Salesforce ID, go back from 18 to 15, and compare IDs in Apex without false mismatches.

This Tutorial Covers: