Free Online Salesforce Formula Playground
Write a Salesforce formula, add sample field values as JSON and see the result, its type and any error, or run it over several rows. A learning subset of the formula language, with no Salesforce org needed.
Press Run, or Ctrl or Cmd + Enter. Fields holds sample values as JSON: one object, or a list of objects to run the formula once per row.
Preview
Console
Output appears here. Press Run, or Ctrl or Cmd + Enter.
How to use
Write the formula in the Formula tab. The character count against the 3,900 limit is shown with the result. Comments written as /* ... */ are allowed.
Open the Fields tab and enter sample values as JSON. A plain object such as { "Amount": 1500, "Name": "Acme" } gives one result. Names are not case sensitive, and a name such as Account.Name looks inside an Account object.
Plain values are typed for you: numbers are Number, true and false are Checkbox, a text like "2024-03-05" is a Date, "2024-03-05T14:30:00Z" is a DateTime, and everything else is Text.
For what cannot be guessed, write the type out: { "Stage": { "type": "Picklist", "value": "Closed Won" }, "Amount": { "type": "Currency", "value": 1500 } }. The types are Text, Number, Currency, Percent, Checkbox, Date, DateTime, Time and Picklist. A Percent is written as the percentage, so 15 means 15%.
Press Run, or Ctrl or Cmd + Enter. The preview shows the result with its type, the field values with the types that were used, and, for an error, the formula with the place marked. The Console repeats the result or the error with its line and column.
To try the same formula on several records, make the Fields tab a list of objects. The formula runs once per row and the preview shows one table row each.
Press Format to put long IF and CASE formulas on several lines with one argument per line. Download gives a zip with a page that shows the last result and the code as source files.
Why use this tool
Result, type and length
See the value, its Salesforce type (Text, Number, Currency, Percent, Checkbox, Date, DateTime or Time) and how many of the 3,900 allowed characters the formula uses.
Errors with the place marked
Syntax errors, unknown fields and functions, wrong parameter counts and type mismatches are reported in Salesforce's style, with the line and column and the spot marked in the formula.
Typed sample fields
Plain JSON values are typed by their shape. An explicit form covers Picklist, Currency, Percent and Time, so picklist rules such as ISPICKVAL() and TEXT() behave as they should.
One formula, many rows
Give the Fields tab a list of objects to run the formula once per record and compare the results in a table. Useful for checking the edge cases of a rule.
A broad function list
Logical: IF, CASE, AND, OR, NOT, BLANKVALUE, NULLVALUE, ISBLANK, ISNULL, ISNUMBER, ISPICKVAL. Text: BEGINS, CONTAINS, FIND, LEFT, RIGHT, MID, LEN, LOWER, UPPER, TRIM, LPAD, RPAD, SUBSTITUTE, TEXT, VALUE, BR, INITCAP, REGEX, HYPERLINK, CASESAFEID. Math: ABS, CEILING, FLOOR, MCEILING, MFLOOR, ROUND, MROUND, TRUNC, MAX, MIN, MOD, EXP, LN, LOG, SQRT. Date and time: TODAY, NOW, TIMENOW, DATE, DATEVALUE, DATETIMEVALUE, TIMEVALUE, YEAR, MONTH, DAY, HOUR, MINUTE, SECOND, MILLISECOND, WEEKDAY, DAYOFYEAR, ADDMONTHS.
Operators and precedence
+ - * / ^, unary minus, = == != <> < > <= >=, && || !, and & or + to join text, with the usual order: ^ first, then unary signs, * /, + - &, comparisons, && and ||.
Date arithmetic
Date plus or minus a number of days, Date minus Date in days, DateTime plus or minus days with fractions, and Time plus or minus milliseconds.
Editor support
Colours for function names, fields, text, numbers and comments, an unknown function name shown in red, and a Format button that puts long calls on several lines.
About this tool
Write a Salesforce formula, give it sample field values and see the result, its type and any error straight away. It is a learning and testing aid for the formula language used in formula fields, validation rules and workflow or flow conditions: IF, CASE, TEXT, date arithmetic, text functions and the rest. The formula is read and evaluated by our own code in your browser. It does not connect to Salesforce: no org or login is needed, and the field values are ones you type. It is a subset of the real language and has not been checked against a live org, so treat a result as a good first answer and confirm it in your own org before you rely on it. This site is not affiliated with or endorsed by Salesforce.
Frequently asked questions
The built-in example labels opportunities from a picklist, a currency and a date, over four rows. Some others to paste in, with matching fields: ROUND(Price * (1 - Discount), 2) with Discount as a Percent; First & IF(ISBLANK(Middle), '', ' ' & Middle) & ' ' & Last; CEILING(MONTH(CloseDate) / 3) for the quarter; CloseDate - TODAY() for days to go; CASE(TEXT(Stage), 'Closed Won', 1, 'Closed Lost', 0, -1); ADDMONTHS(TODAY(), 1) - 1 for a date a month ahead; REGEX(Zip, '[0-9]{5}') for a validation rule; CASESAFEID('001D000000IRFma') for the 18 character id.
No. It is our own implementation of a large part of the formula language, written from the documented behaviour and tested with many cases, but it has not been compared with a live org. Edge cases can differ, so check an important formula in a sandbox. The sections below list the differences we know about.
No to both. The formula and the sample values are read in your browser. That is also why it cannot use your real records: you supply the field values.
Like Salesforce's default option, treat blank fields as zeroes. A blank Number, Currency or Percent counts as 0 in sums and comparisons, a blank Text counts as empty text, and a blank Date stays blank. ISBLANK() is true for all of them. The other option, treat blank fields as blanks, is not available.
UTC everywhere. TODAY() is the UTC date when you pressed Run, and NOW() is that moment. A real org uses the time zone of the running user for some functions, so a result near midnight can differ.
A number is a Number, true or false is a Checkbox, "2024-03-05" is a Date, "2024-03-05T14:30:00Z" (or with an offset, or without a zone, which means UTC) is a DateTime, null is a blank of no type, and any other text is Text. Use { "type": "Picklist", "value": "..." } for picklists and the typed form for Currency, Percent and Time.
As in Salesforce, a picklist can only be used with ISPICKVAL(), TEXT(), ISBLANK() and CASE(TEXT(field), ...). Comparing it with = or passing it to LEN() is an error. Declare the field as a picklist in the Fields tab to see this.
Salesforce checks the types in a formula when you save it. The same happens here, using the types of the sample values. For example, LEN(Amount) needs Text, YEAR() needs a Date and not a DateTime (use DATEVALUE first), and both branches of an IF must have the same type, even the branch that is not used.
It is an error that points at the divisor. In a formula field Salesforce shows #Error! for it. A branch that is not taken is not evaluated for runtime errors, so IF(Qty = 0, 0, Total / Qty) works. AND() and OR() evaluate all their arguments, so AND(Qty <> 0, Total / Qty > 1) fails when Qty is 0. We believe a real org behaves the same, but have not verified it.
ROUND, MROUND and TRUNC round half away from zero, so 2.5 becomes 3 and -2.5 becomes -3. Results are kept to 15 significant digits so that 0.1 + 0.2 is 0.3. Salesforce uses decimal numbers with more digits, so very long results can differ.
MOD takes the sign of the first number, like Apex's Math.mod, so MOD(-5, 3) is -2. CEILING rounds away from zero and FLOOR rounds toward zero, which is how we read Salesforce's documentation: CEILING(-2.1) is -3 and FLOOR(-2.9) is -2. MCEILING and MFLOOR are the mathematical versions. We have not verified these against an org, so test them there if a rule depends on them.
= and != ignore case, and so do < and >. CONTAINS, BEGINS, FIND and SUBSTITUTE are case sensitive. CASE and ISPICKVAL ignore case here, which we are not certain matches Salesforce. REGEX must match the whole text, and uses JavaScript's regular expression syntax, not Java's. A leading (?i) is understood, but other Java-only features such as possessive quantifiers are not.
Anything that needs a real org or record history: ISNEW, ISCHANGED, PRIORVALUE, VLOOKUP, GETSESSIONID, IMAGE, URLFOR, LINKTO, CURRENCYRATE, DISTANCE, the encode functions and similar. They give a clear message instead of a wrong answer. $User, $Profile and other global variables work only if you add them to the Fields tab as nested objects. IFS is not a Salesforce formula function and is not accepted. INITCAP is included because it was requested, but we are not sure the real formula language has it.
It returns the label text as the result and notes the link in the preview and the Console. The link is not opened.
No. Only the 3,900 character length is counted and flagged. The compiled size depends on how Salesforce expands your fields and functions, which we cannot reproduce.
The code in both tabs is kept in this browser on this device. Saved code is never run when you open the page; only the built-in example runs on a first visit.
Formulas have no loops, but a REGEX() pattern can take very long on some text. The formula runs in a separate worker that is stopped after 4 seconds, and the Console says so.