Skip to main content

SOQL Parser JS

Parse and generate SOQL queries

Parse

SELECT Name
FROM Account
WHERE Industry = 'media'
ORDER BY BillingPostalCode ASC NULLS LAST
LIMIT 125

into

{
"fields": [
{
"type": "Field",
"field": "Name"
}
],
"sObject": "Account",
"where": {
"left": {
"field": "Industry",
"operator": "=",
"literalType": "STRING",
"value": "'media'"
}
},
"orderBy": [
{
"field": "BillingPostalCode",
"order": "ASC",
"nulls": "LAST"
}
],
"limit": 125
}

Compose

{
"fields": [
{
"type": "Field",
"field": "Name"
}
],
"sObject": "Account",
"where": {
"left": {
"field": "Industry",
"operator": "=",
"literalType": "STRING",
"value": "'media'"
}
},
"orderBy": [
{
"field": "BillingPostalCode",
"order": "ASC",
"nulls": "LAST"
}
],
"limit": 125
}

into

SELECT Name
FROM Account
WHERE Industry = 'media'
ORDER BY BillingPostalCode ASC NULLS LAST
LIMIT 125

Battle Tested

Your SOQL query is parsed using a language parser, Chevrotain JS, and aims to support every SOQL feature.

This library has been powering Jetstream in production for many years and has parsed and composed millions of queries from thousands of users.