Excel Formula to JavaScript Converter

Paste a spreadsheet formula and get readable JavaScript: a function with named parameters, correct operator precedence and small helper functions for things JavaScript lacks, such as SUMIFS and VLOOKUP.

Runs in your browserUpdated

Paste with or without the leading =. Commas and semicolons both work as argument separators.

Output

Cell references

References appear here once you enter a formula.

Give references meaningful names (B2 → price). Ranges become lists; multi-column ranges become lists of rows.

Your data never leaves your computer. All processing happens 100% locally in your browser.

How to use the Excel Formula to JavaScript

  1. Paste an Excel or Google Sheets formula, or pick one from Examples.
  2. Choose the target language — the page starts with JavaScript, and you can switch at any time.
  3. Rename the detected cell references to meaningful variable names, for example B2 → price.
  4. Choose a full function or the bare expression, then copy or download the code. Helper functions are added automatically when a formula needs them.

Why convert Excel formulas to JavaScript?

Business logic often starts life in a spreadsheet: a pricing model, a commission table, an eligibility check. When that logic moves into a web app, a Node.js API or a Google Apps Script, every formula has to be rewritten by hand — and subtle differences between Excel and JavaScript cause bugs that only show up with real data. This converter parses the formula exactly as Excel does and writes equivalent JavaScript.

=IF(AND(B2>=18, C2="yes"), "Eligible", "Not eligible")

function calculate(B2, C2) {
  return B2 >= 18 && C2 === 'yes' ? 'Eligible' : 'Not eligible';
}

How Excel functions map to JavaScript

ExcelJavaScript
IF(c, a, b)c ? a : b
IFS / SWITCHnested ternaries
AND, OR, NOT&&, ||, !
= and <>=== and !==
a & bString(a) + b
a ^ ba ** b
SUM(A2:A10)A2_A10.reduce(…)
ROUND(x, 2)round() helper (half away from zero)
MOD(a, b)mod() helper
SUMIFS / COUNTIF…sumIfs(), countIf() helpers
VLOOKUP / XLOOKUPvlookup(), xlookup() helpers
IFERROR(x, y)ifError(() => x, y)
LEFT / MID / LEN.slice(), .substr(), .length
TODAY() / NOW()new Date()

Differences that cause bugs

  • Operator precedence. In Excel =-2^2 is 4 because negation binds tighter than ^. JavaScript does not even allow -2 ** 2. The converter always adds the parentheses Excel implies: (-2) ** 2.
  • Rounding. Excel rounds halves away from zero; Math.round(-2.5) returns −2 and (1.005).toFixed(2) gives "1.00". The generated round() helper matches Excel.
  • Remainders. MOD(-7, 3) is 2 in Excel but -7 % 3 is −1 in JavaScript, so a mod() helper is used.
  • Text comparison. Excel's = ignores case for text; === does not. Lookups and criteria helpers compare case-insensitively like Excel.
  • Concatenation. & always produces text, while + adds numbers. The converter wraps the first operand in String() so A1 & B1 never turns into a sum.
  • Errors. Division by zero returns Infinity instead of throwing, so ifError() checks for non-finite results as well as exceptions.

Ranges, lookups and criteria

A single-column or single-row range such as A2:A100 becomes an array parameter; a multi-column range such as A2:C500 becomes an array of rows, which is the shape vlookup() expects. Criteria strings work like in Excel: ">=1000", "<>closed" and wildcards such as "*@example.com".

Supported functions: IF, IFS, SWITCH, AND, OR, NOT, XOR, IFERROR, IFNA, ISBLANK, ISNUMBER, ISTEXT, SUM, AVERAGE, MIN, MAX, COUNT, COUNTA, COUNTBLANK, PRODUCT, MEDIAN, ROUND, ROUNDUP, ROUNDDOWN, INT, TRUNC, ABS, SIGN, MOD, POWER, SQRT, EXP, LN, LOG, LOG10, PI, CEILING, FLOOR, RAND, RANDBETWEEN, SUMIF, SUMIFS, COUNTIF, COUNTIFS, AVERAGEIF, AVERAGEIFS, SUMPRODUCT, VLOOKUP, XLOOKUP, MATCH, INDEX, CONCAT, CONCATENATE, TEXTJOIN, LEFT, RIGHT, MID, LEN, UPPER, LOWER, PROPER, TRIM, SUBSTITUTE, REPLACE, FIND, SEARCH, REPT, VALUE, EXACT, TEXT (number formats), TODAY, NOW, DATE, YEAR, MONTH, DAY. Anything else is kept as a call and listed so you can implement it. Need the data too? Turn the sheet into an array with Excel to JavaScript array.

Tools that pair well with the Excel Formula to JavaScript

  • Excel Formula to Python — Paste an Excel or Google Sheets formula and get a Python function with clean variable names, the right imports and helpers for SUMIFS, VLOOKUP and Excel-style rounding.
  • Excel Formula to PHP — Paste a spreadsheet formula and get a PHP 8 function: parenthesised ternaries, mb_* string functions, and helpers for lookups, conditional sums and Excel-style MOD.
  • Excel Formula to SQL — Paste an Excel formula and get the equivalent SQL expression or SELECT query — IF and IFS as CASE WHEN, SUMIFS and COUNTIFS as conditional aggregates, and the right string and date functions for your database.
  • JavaScript Formatter — Unminify and pretty-print JavaScript, JSON or JSX with your preferred indentation and brace style — or strip whitespace and comments with a verified minifier.

Frequently asked questions

Does the generated JavaScript give the same results as Excel?
For the supported functions, yes — including Excel-style rounding, MOD signs and case-insensitive lookups. Dates are JavaScript Date objects rather than Excel serial numbers, so date arithmetic such as A2 + 30 needs adapting.
Can I use it for Google Sheets formulas or Apps Script?
Yes. Google Sheets uses the same formula syntax for the supported functions, and the output runs unchanged in Google Apps Script, browsers and Node.js.
What happens to functions it does not know?
They are kept as function calls with the same name (for example networkdays(…)) and listed above the output so you can implement or replace them.
Is my formula sent to a server?
No. Parsing and code generation run entirely in your browser.
How are cell references named?
By default B2 stays B2 and A2:A10 becomes A2_A10. Type a name next to any reference to rename it everywhere in the output.

Related tools