Skip to main content

sf-formula-parser

Parse and evaluate Salesforce formulas entirely client-side. Zero dependencies. 90+ functions. TypeScript-first.

import { evaluateFormula } from 'sf-formula-parser';

const result = evaluateFormula(
'IF(Amount > 1000, "Large", "Small")',
{ record: { Amount: 5000 } }
);
// => "Large"
$ npm install @jetstreamapp/sf-formula-parser
Get StartedTry the Playground
fx

90+ Functions

Logical, math, text, and date/time functions — all matching real Salesforce behavior, including edge cases.

0

Zero Dependencies

Pure TypeScript compiled to ESM. No Node.js APIs, no runtime dependencies. Works in browsers, Node, Deno, and edge functions.

{}

Full AST Access

Parse formulas into a typed AST for inspection, caching, or building your own tooling on top of the formula language.

Aa

Case-Insensitive

IF, if, If — all work, just like Salesforce. No surprises.

?:

Lazy Evaluation

IF, CASE, IFS only evaluate the branch that's taken. Side effects in untaken branches are skipped.

->

Related Records

Traverse relationships like Account.Name or Contact.Account.Industry with nested record contexts.