Swelıty
Tools for everyone

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

  1. 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.

  2. 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.

  3. 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.

  4. 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%.

  5. 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.

  6. 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.

  7. 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.