Free SOQL Query Builder
Build Salesforce SOQL queries visually — connect your org to browse all objects and fields, add WHERE filters, ORDER BY, and get a ready-to-copy query instantly.
Connect your Salesforce org to browse objects and fields.
Generated SOQL
What is SOQL?
SOQL (Salesforce Object Query Language) is the query language used to retrieve data from your Salesforce org. It works like SQL but is designed specifically for the Salesforce data model — supporting relationship queries, date literals, and Salesforce-specific aggregate functions. Every Salesforce developer needs SOQL to build Apex classes, reports, and integrations.
SOQL vs SQL — Key Differences
| Feature | SOQL | SQL |
|---|---|---|
| Read only | Yes (no INSERT/UPDATE/DELETE) | No (full DML) |
| Date literals | THIS_MONTH, LAST_YEAR, LAST_N_DAYS:n | No |
| Relationship queries | Parent dot notation + child subqueries | JOINs |
| Governor limits | 50,000 rows max per transaction | No limit |
| Wildcards | LIKE with % and _ | Same |
SOQL Date Literals
One of SOQL's most powerful features is date literals — dynamic date values that resolve at query time without hardcoding dates. Use them in WHERE clauses to filter records relative to today:
| Literal | Meaning |
|---|---|
TODAY | The current day (midnight to midnight) |
THIS_WEEK | Sunday through Saturday of the current week |
THIS_MONTH | First to last day of the current month |
THIS_QUARTER | Current fiscal quarter |
THIS_YEAR | Jan 1 to Dec 31 of the current year |
LAST_N_DAYS:n | Last n days, e.g. LAST_N_DAYS:30 |
NEXT_N_DAYS:n | Next n days from today |
Example: SELECT Id, Name FROM Opportunity WHERE CloseDate = THIS_QUARTER
SOQL Relationship Queries
SOQL supports two types of relationship queries — a feature SQL developers need JOINs for.
- Child-to-parent (dot notation): Access parent fields directly.
SELECT Name, Account.Name FROM Contact - Parent-to-child (subquery): Retrieve child records inside the parent query.
SELECT Name, (SELECT LastName FROM Contacts) FROM Account
Common SOQL Mistakes
- No WHERE on large objects — querying Account or Contact without a WHERE clause will hit the 50,000 row governor limit in most orgs.
- Selecting too many fields — each field in SELECT counts against query column limits. Select only what you need.
- Using 15-char IDs in WHERE — always use 18-character IDs in SOQL WHERE clauses for case-insensitive matching.
- Forgetting single quotes — string values in SOQL must be in single quotes:
WHERE Name = 'Acme' - Missing LIMIT on large result sets — always add a LIMIT clause when building and testing queries to avoid consuming governor limits unexpectedly.
How to Use This SOQL Query Builder
- Connect your org — click "Connect Production Org" or "Connect Sandbox" and log in with your Salesforce credentials.
- Select an object — search and pick the Salesforce object you want to query (e.g. Account, Contact, Opportunity).
- Pick fields — move fields from "Available" to "Selected". These become your SELECT clause.
- Add filters — use the WHERE section to add conditions. The operator list adapts to each field's type.
- Set ORDER BY and LIMIT — control sort order and the number of rows returned.
- Copy or share — click "Copy" to grab the SOQL, "Share URL" to create a shareable link, or "Open in Workbench" to run the query directly.
Frequently Asked Questions
What is SOQL?
SOQL (Salesforce Object Query Language) is a query language used to search your organization's Salesforce data. It is similar to SQL but designed specifically for the Salesforce platform.
Do I need a Salesforce org to use this tool?
You need a connected Salesforce org to browse your objects and fields. Connect your production or sandbox org with one click — your credentials are handled securely by Salesforce OAuth and never stored by us.
Is my data safe?
Yes. Authentication uses Salesforce's standard OAuth 2.0 flow. Your access token is stored only in your browser's sessionStorage for the duration of the session and is never persisted on our servers.
What is the difference between SOQL and SQL?
SOQL is a read-only query language — it cannot INSERT, UPDATE, or DELETE records. It supports Salesforce-specific features like relationship queries, date literals (THIS_MONTH, LAST_YEAR), and governor limit considerations.
What are Salesforce governor limits for SOQL queries?
In a single Apex transaction, you can retrieve up to 50,000 records with SOQL. The maximum LIMIT you can specify is 50,000. Large objects like Account, Contact, and Lead should always include a WHERE clause to avoid hitting these limits.
Can I use this SOQL builder for sandbox orgs?
Yes. The tool supports both production and sandbox Salesforce orgs. Click "Connect Sandbox" to authenticate against test.salesforce.com instead of login.salesforce.com.