Stepthrough Start free

n8n If Node Number Comparisons: Totals, Scores, Wrong Type

Quick answer

To compare numbers in an n8n If node, put the number in value1, open the comparison and choose an operator under Number, such as is greater than, then type a plain number in value2: 1000, not $1,000. If n8n says "Wrong type: ... is a string but was expecting a number", the value arrived as text; fix the source or turn on type conversion. The free invoice approval lesson routes invoices over $1,000 this way.

Last updated

Take the free module →Module 13 of the free AI for Accounting & Bookkeeping Firms course, about 14 minutes. No account needed.

n8nIf nodeTroubleshooting

How do I check if a total is over $1,000?

  1. Add an If node after the step that has the total.
  2. In value1, paste {{ $('Information Extractor').item.json.output.total }}.
  3. Open the comparison (it says is equal to) and under Number choose is greater than.
  4. In value2, type 1000. No dollar sign, no comma.

Items above 1000 go to the true output, the rest to false. In the lesson only the true branch has a next step: the approval email. The glossary explains true and false branches.

How do I check a lead score?

The speed-to-lead lesson does the same with a 1-10 score: value1 {{ $('Information Extractor').item.json.output.score }}, operator Number: is greater than or equal to, value2 8. Hot leads go down the true branch to a Slack alert.

Which number operators are there?

OperatorTrue when value1 is...Example
is equal tothe same numberquantity = 0
is not equal toany other numberstatus code is not 200
is greater thanlargertotal > 1000
is less thansmallerscore < 5
is greater than or equal tolarger or the samescore >= 8
is less than or equal tosmaller or the samedays left <= 3
exists / does not existpresent or missinga total was found at all

"Wrong type: '1,240.00' is a string but was expecting a number"

The If node got text, not a number. Common causes: a sheet column formatted as currency, an AI answer with a $ sign, or a webhook that sends every value as text.

Fixes, best first:

  1. Get a real number at the source. The invoice lesson's extractor prompt asks for "the final amount due, as a number with no $ sign", and its JSON example uses 250.75, not "$250.75".
  2. Convert in the expression: {{ Number($json.Total.replace(/[$,]/g, '')) }}.
  3. Let the If node convert: turn on its option to convert types where required (loose type validation).

Why does "is greater than" give the wrong answer?

If both values are treated as text, "999" is "greater" than "1000" because 9 comes after 1. Make sure you picked the operator under Number, not String.

Try it free, step by step

Invoices from Your Inbox to Google Sheets, with Approval. Build an n8n workflow that reads each vendor invoice PDF from Gmail with AI, logs the vendor, invoice number and total in Google Sheets, and emails the owner an Approve button for anything over… You do every step yourself in a practice copy of n8n, it checks your work as you go, and “Do it for me” finishes any step you get stuck on. Free, and nothing touches your real accounts.

Start the free lesson

Or read the full step-by-step guide

Should I use If, Filter or Switch?

  • If: two paths, both may continue (approval vs log only).
  • Filter: keep only matches, drop the rest.
  • Switch: three or more paths, such as amount bands. n8n If vs Switch compares them.

Key takeaways

  • Choose the operator under Number, and type value2 as a plain number.
  • Map the number from the node that made it, often the Information Extractor.
  • "Wrong type ... is a string" means text arrived; fix the source or convert.
  • Ask AI extractors for numbers without $ signs or commas.

Frequently asked questions

How do I compare numbers in n8n?

Use an If or Filter node, choose a Number operator such as is greater than, and enter a plain number as value2.

Why does my n8n If node say wrong type?

The value is a string, not a number. Convert it with Number() in the expression, or turn on the If node's type conversion option.

Can I compare against a value from another node?

Yes. value2 can be an expression too, like a limit stored in a settings sheet.

Which course is this from?

AI for Finance Teams and AI for Sales Teams. Also see the If node glossary entry.

Free lessons in this post

Plain-English definitions, each with an example from a free lesson.

The full AI glossary

All free prompt templates

Keep reading

All blog posts · All free tutorials