Free Online SOQL Playground
Write SOQL and SOSL queries and run them against built-in invented sample data, with the results in tables. A learning subset of the language; no Salesforce account needed.
Press Run, or Ctrl or Cmd + Enter, to run every statement in the editor. The data is invented sample data with no connection to any Salesforce org, and it is created fresh on every run, so nothing carries over from one run to the next. Dates are UTC.
Preview
Console
Output appears here. Press Run, or Ctrl or Cmd + Enter.
How to use
Write one or more statements in the editor, or start from the example. Separate statements with a semicolon. Comments start with //.
Press Run, or Ctrl or Cmd + Enter. Every statement runs, in order, and each one gets a section in the preview.
Read the row count and the table. A SOQL result with COUNT() shows the count. A SOSL search shows one table for each object in RETURNING.
If a statement has a mistake, its error appears in the preview and in the Console with the line and column. The other statements still run.
Open the Schema section under the results to find object names, field names, types, picklist values and relationship names such as Contacts or Owner.
Press Format to put keywords in capitals and each clause on its own line. Press Stop to cancel a run, and Download to save a zip with a standalone page and your query as a .soql file.
Why use this tool
Our own SOQL and SOSL engine
A real parser and evaluator written for this site. It reads your query as text and runs it over in-memory sample data.
Relationships both ways
Parent fields up to five levels (Owner.Manager.Name) and child subqueries such as (SELECT LastName FROM Contacts), plus semi-joins and anti-joins with IN and NOT IN (SELECT ...).
Aggregates and grouping
COUNT(), COUNT(field), COUNT_DISTINCT, SUM, AVG, MIN, MAX, aliases, GROUP BY, HAVING and the calendar functions such as CALENDAR_YEAR(CloseDate).
Date literals that follow today
TODAY, LAST_N_DAYS:30, THIS_QUARTER and the rest are worked out from the day you run the page, and the sample dates are offsets from today, so these queries always find something.
Clear errors
Messages such as unexpected token: 'FORM' and No such column 'Foo' on entity 'Account' come with the line and column in your text.
A built-in schema reference
Every object, field, type, picklist value and relationship the sample data has, listed under the results.
Safe by design
The query engine runs in a worker that is stopped after five seconds. The result is shown in an isolated frame with no scripts.
About this tool
Write SOQL and SOSL queries and run them in your browser, with the results in tables. The queries run against a built-in set of invented sample data (accounts, contacts, opportunities, leads, cases, users, tasks, campaigns, products and opportunity line items), so you can practise without a Salesforce org, a login or a sandbox. The playground has its own SOQL and SOSL parser and query engine. It is a learning subset of the language, not the real platform: it does not connect to Salesforce, and the data is made up and has nothing to do with any org. This site is not affiliated with or endorsed by Salesforce.
You can run several statements at once, separated by semicolons. Each one shows its row count and a table, with parent fields such as Account.Name as columns and child subqueries as small nested tables. Errors are reported the way Salesforce reports them, with the line and column. A Schema section under the results lists every object and field you can query, with types, picklist values and relationship names.
Frequently asked questions
No. It never contacts Salesforce or any other service, and you do not log in. Your queries run in your browser against sample data that this site made up. The sample records are not real, and the ids, names and numbers are invented.
It is a subset, written to follow the language closely, and it is for learning and for trying out a query shape. It is not the Salesforce query engine, so results, limits, sharing, field permissions and performance will differ in a real org. Test anything important in a sandbox.
SELECT field lists, relationship paths up to five levels, child subqueries, a FROM alias, aggregate functions with aliases, GROUP BY and HAVING, WHERE with AND, OR, NOT and brackets, the operators = != <> < > <= >=, LIKE with % and _, IN and NOT IN with a list, a bind variable or a subquery (semi-join and anti-join), INCLUDES and EXCLUDES on multi-select picklists, null checks, date and datetime values, date literals (TODAY, YESTERDAY, TOMORROW, LAST_WEEK, THIS_MONTH, NEXT_MONTH, LAST_N_DAYS:n, NEXT_N_DAYS:n, LAST_N_MONTHS:n, THIS_QUARTER, THIS_YEAR, LAST_YEAR, N_DAYS_AGO:n and similar), the calendar functions, FORMAT, toLabel and convertCurrency (which pass the value through), ORDER BY with several fields, ASC, DESC and NULLS FIRST or LAST, LIMIT, OFFSET and ALL ROWS.
FIND with a term in braces, wildcards * and ?, quoted phrases and the operators AND, OR and AND NOT (written in capitals), IN ALL, NAME, EMAIL, PHONE or SIDEBAR FIELDS, RETURNING with a field list, WHERE, ORDER BY, LIMIT and OFFSET for each object, and a LIMIT for the whole search. Words next to each other mean OR. Results are not ranked, and WITH clauses are accepted and ignored.
TYPEOF, GROUP BY ROLLUP and CUBE, GROUPING(), WITH DATA CATEGORY, geolocation functions, currency literals such as USD100, FIELDS(ALL), custom objects, standard objects other than the ten listed in the Schema, the Tooling and Bulk APIs, and DML (insert, update, delete): this playground only queries. Dates are in UTC and the fiscal year is the calendar year.
They are accepted so that a query copied from your own code still runs, and they are ignored. A note under the statement says so. The sample data has no field permissions, sharing, ownership scopes or record locks.
The sample database is created fresh for every run, so nothing carries over from one run to the next. Your query text is kept in this browser on this device, and is never run again until you press Run. After you clear the editor, the example is shown again the next time you visit.
Every date in the sample data is an offset from the day you run the page, so TODAY, YESTERDAY, THIS_MONTH, LAST_N_DAYS:30 and NEXT_N_DAYS:30 always return something. The same day gives the same data, with no randomness.
The preview shows up to 200 rows of each result and tells you the full count, for example Showing the first 200 of 340 rows. The sample data is small, so most queries return far fewer. A run that takes longer than five seconds is stopped.
A zip with a standalone index.html and a source folder. The page shows your query and, if you have pressed Run since your last edit, its result, and it works without this site. The source folder holds your query as query.soql.