sObject
An sObject (Salesforce Object) is the Apex representation of a Salesforce standard or custom object.
Definition
An sObject (Salesforce Object) is the Apex representation of a Salesforce standard or custom object. In Apex code, sObject is the generic data type that can represent any record, and specific sObjects like Account, Contact, or MyCustomObject__c are strongly-typed subtypes. Developers use sObjects to create, read, update, and delete records programmatically.
In plain English
“Here's a simple way to think about it: sObject is the type developers reach for when code shouldn't care about object specifics. Account is an sObject, Custom__c is an sObject; generic code that works on records of any type uses the abstraction.”
Worked example
A developer writes Apex code to create a new Account: Account acc = new Account(Name = 'TechCorp', Industry = 'Technology'); insert acc; Here, "acc" is an sObject of type Account. The developer can also use the generic sObject type: sObject genericRecord = acc; This flexibility allows utility methods that work across any object type.
Why sObject is the type developers reach for when the code shouldn't care about object specifics
In Apex, every Salesforce object is also an sObject - the generic data type for any record, regardless of which specific object it represents. Account is an sObject, MyCustomObject__c is an sObject, the result of a SOQL query that hasn't been bound to a specific type is an sObject. Developers use the generic sObject type when writing code that operates on records without needing to know in advance which object the records belong to.
The reason this matters in practice is that sObject is what makes meta-programming possible in Apex. Code that handles records dynamically - generic update logic, validation that runs across many objects, integration code that consumes a stream of any record type - depends on the sObject abstraction. The trade-off is loss of compile-time type safety; specific sObject types catch errors that generic sObject doesn't. Use the generic when the code legitimately needs to work across types; use specific types when you can.
How to create sObject
sObject (Salesforce Object) is the umbrella term for every object — standard, custom, external, big, junction, platform event. In Apex, every record is typed as the sObject base class or a specific subclass. This page covers what you can do at the sObject layer in code and metadata.
- Decide the kind of sObject you need
Standard / Custom / External / Big Object / Platform Event. Each has its own Setup path — see those entries.
- For Custom Objects: Setup → Object Manager → Create → Custom Object
Most net-new sObjects start here. The wizard walks through Label, Object Name, Record Name.
- For Apex code: declare with the sObject type
Apex: Account a = new Account(Name='Acme'); insert a; — sObject is the base class, Account is the specific subclass.
- For dynamic Apex: cast to sObject
Apex: sObject obj = Database.query('SELECT Id FROM Account LIMIT 1'); — useful when the object type isn't known at compile time.
- Configure metadata via Object Manager
Fields, Layouts, Validation Rules, Record Types, Automation — all per sObject.
- sObject is the base class, but specific subclasses (Account, Contact) have their own typed fields. Casting between them at runtime requires careful instanceof checks.
- Dynamic Apex DML is more error-prone than typed DML. Use only when the object type is genuinely unknown at compile time — typed DML is faster and safer.
- Some Salesforce APIs return generic sObjects (Tooling API, Metadata API). Cast with try/catch when extracting field values.
How organizations use sObject
Generic update logic uses sObject type; one Apex class handles 12 different objects rather than 12 specific classes.
Integration consumer takes sObject input; receives records of any type and routes appropriately.
Trust & references
Straight from the source - Salesforce's reference material on sObject.
- SObject TypesSalesforce Developers
🧠 Test your knowledge
Q1. What is a Governor Limit in the context of sObject?
Q2. What skill set is typically needed to work with sObject?
Q3. Where would a developer typically work with sObject?

Discussion
Loading discussion…