Salesforce Dictionary - Free Salesforce GlossarySalesforce Dictionary
Full Record ID entry
How-to guide

Convert and validate a Record ID

Find, copy, and convert a Record ID between its 15- and 18-character forms for use in URLs, API calls, and integration payloads.

By Dipojjal Chakrabarti · Founder & Editor, Salesforce DictionaryLast updated May 26, 2026

Find, copy, and convert a Record ID between its 15- and 18-character forms for use in URLs, API calls, and integration payloads.

  1. Locate the ID in the URL

    Open the record in Lightning or Classic. The path includes the 15-character ID, for example /lightning/r/Account/0014x000004Pq1qAAC/view. Copy the segment that begins with the object key prefix.

  2. Use the developer console

    Open the Developer Console, Debug, Open Execute Anonymous. Run System.debug([SELECT Id FROM Account LIMIT 1]). The 18-character ID prints in the log. This is the safest copy path for any integration script.

  3. Convert 15 to 18 via formula

    Create a formula field of type Text using the CASESAFEID() function on Id. The field always returns the 18-character form. Use this on report exports and CSV downloads to give Excel users a safe identifier.

  4. Verify the key prefix

    Match the first three characters against the object you expect. If they do not match, the integration has crossed wires somewhere. A quick prefix audit catches most mismatched-object bugs at the boundary instead of downstream.

  5. Test case sensitivity in the destination

    If the receiving system (Excel, an Outlook plug-in, a flat file) might fold case, store the 18-character form. Round-trip one known ID through your pipeline and confirm it returns equal byte-for-byte before going live.

Key options
15-character formremember

Case-sensitive. Used by the Salesforce UI and the legacy SOAP API. Safe inside Salesforce but unsafe in external systems that fold case.

18-character formremember

Case-insensitive (the last 3 characters are a checksum). Safe everywhere. Default for REST API, LWC, and modern integrations.

CASESAFEID() formularemember

Salesforce formula function that returns the 18-character form of any record Id. Useful in report-exported text fields.

External ID fieldremember

Custom field marked Unique and External ID. Holds an outside-system identifier. Separate from the Record ID.

Gotchas
  • Excel and many email clients fold case on Salesforce IDs. Always export the 18-character form, not the 15, when the destination might lowercase or uppercase the string.
  • Record IDs change across orgs. Never hard-code an ID in Apex or a formula; reference Custom Metadata or a Custom Setting that holds the environment-specific value.
  • The first three characters identify object type, but custom objects share the prefix range. Two custom objects in different orgs can have the same key prefix, so the prefix alone does not uniquely identify your object across orgs.
  • Deleted records never have their IDs reused. If an integration sees an ID disappear from a query result, the record was soft-deleted or moved out of scope, not renumbered.

See the full Record ID entry

Record ID includes the definition, worked example, deep dive, related terms, and a quiz.