npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

soql-parser-lite

v1.0.1

Published

A TypeScript/JavaScript parser for SOQL (Salesforce Object Query Language) that converts query strings into structured objects with zero dependencies.

Readme

Examples | Documentation

soql-parser-lite

A zero-dependency, TypeScript/JavaScript parser for SOQL (Salesforce Object Query Language) that converts query strings into structured objects.

Features

  • 🔍 Complete SOQL Support: Parses all major SOQL clauses (SELECT, FROM, WHERE, GROUP BY, HAVING, ORDER BY, LIMIT, OFFSET)
  • 📦 TypeScript First: Fully typed API with comprehensive type definitions
  • 🚀 Zero Dependencies: Lightweight with no external runtime dependencies
  • 🔄 Streaming Support: Can parse queries incrementally from streams
  • 🎯 Accurate: Handles complex queries including subqueries, aggregate functions, and nested field paths
  • 🛡️ Error Handling: Provides detailed error messages for malformed queries

Installation

npm install soql-parser-lite

Or with pnpm:

pnpm add soql-parser-lite

Or with yarn:

yarn add soql-parser-lite

Quick Start

import { parseSoqlQuery } from 'soql-parser-lite'

// Parse a simple query
const query = parseSoqlQuery(
    'SELECT Id, Name FROM Account WHERE Status = "Active" LIMIT 10',
)

console.log(JSON.stringify(query, null, 2))

// Output:
/*
{
  "select": {
    "items": [
      {
        "item": {
          "name": "Id"
        }
      },
      {
        "item": {
          "name": "Name"
        }
      }
    ]
  },
  "from": {
    "objects": [
      {
        "name": "Account"
      }
    ]
  },
  "where": {
    "expr": {
      "left": {
        "name": "Status"
      },
      "right": {
        "value": "Active"
      }
    }
  },
  "limit": 10
}
*/

Usage Examples

Basic Query

import { parseSoqlQuery } from 'soql-parser-lite'

const query = parseSoqlQuery('SELECT Id, Name, Email FROM Contact')

Query with WHERE Clause

const query = parseSoqlQuery(
    'SELECT Id, Name FROM Account WHERE Status = "Active" AND Revenue > 1000000',
)

Query with Aggregate Functions

const query = parseSoqlQuery(
    'SELECT COUNT(Id) cnt, MAX(Amount) maxAmount FROM Opportunity GROUP BY StageName',
)

Query with Subquery

const query = parseSoqlQuery(
    'SELECT Name, (SELECT LastName FROM Contacts) FROM Account',
)

Query with Date Literals

const query = parseSoqlQuery('SELECT Id FROM Case WHERE CreatedDate = TODAY')

Query with ORDER BY and LIMIT

const query = parseSoqlQuery(
    'SELECT Id, Name, CreatedDate FROM Account ORDER BY CreatedDate DESC LIMIT 100 OFFSET 50',
)

Query with Relationship Fields

const query = parseSoqlQuery(
    'SELECT Id, Account.Name, Account.Owner.Email FROM Contact',
)

Supported SOQL Features

  • ✅ SELECT clause with fields, aggregate functions, and subqueries
  • ✅ FROM clause with multiple objects and aliases
  • ✅ WHERE clause with comparison and logical operators
  • ✅ GROUP BY clause
  • ✅ HAVING clause
  • ✅ ORDER BY clause with ASC/DESC
  • ✅ LIMIT clause
  • ✅ OFFSET clause
  • ✅ Date literals (TODAY, YESTERDAY, LAST_N_DAYS, etc.)
  • ✅ Bind variables (:variable)
  • ✅ IN operator with arrays and subqueries
  • ✅ Relationship field paths (Account.Owner.Name)
  • ✅ Aggregate functions (COUNT, MAX, MIN, SUM, AVG)
  • ✅ Field aliases

Development

# Install dependencies
pnpm install

# Build the project
pnpm run compile

# Run tests
pnpm test

# Format code
pnpm run format

# Generate documentation
pnpm run docs:gen

Contributing

Contributions are welcome! Please see CONTRIBUTING.md for details.

License

MIT © Jacob Shirley

Related Projects

Support