<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Robert Breen</title>
    <description>The latest articles on DEV Community by Robert Breen (@robert_breen_d96e41ecd765).</description>
    <link>https://dev.to/robert_breen_d96e41ecd765</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4172249%2Fcd8de2d9-27f9-43a0-9024-fae1e21b45e4.jpg</url>
      <title>DEV Community: Robert Breen</title>
      <link>https://dev.to/robert_breen_d96e41ecd765</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/robert_breen_d96e41ecd765"/>
    <language>en</language>
    <item>
      <title>Excel for the Web: Budget vs Actual With a Table, One Calculated Column and a Greater-Than-0 Rule</title>
      <dc:creator>Robert Breen</dc:creator>
      <pubDate>Wed, 25 Nov 2026 22:00:00 +0000</pubDate>
      <link>https://dev.to/robert_breen_d96e41ecd765/excel-for-the-web-budget-vs-actual-with-a-table-one-calculated-column-and-a-greater-than-0-rule-4020</link>
      <guid>https://dev.to/robert_breen_d96e41ecd765/excel-for-the-web-budget-vs-actual-with-a-table-one-calculated-column-and-a-greater-than-0-rule-4020</guid>
      <description>&lt;p&gt;A budget-vs-actual sheet is the first spreadsheet most small businesses need, and the one most often built as a loose grid of cells with hand-typed totals. The moment someone inserts a row, a SUM range misses it.&lt;/p&gt;

&lt;p&gt;This walkthrough builds it the sturdy way in Excel for the web, using a made-up bakery owner, Tom, whose bookkeeper asks every month where he went over budget. Five lines, and four Excel features that do the work for you:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Format As Table&lt;/strong&gt;, so ranges grow with the data.&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;calculated column&lt;/strong&gt; that fills one formula down by itself.&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;Total Row&lt;/strong&gt;, instead of hand-written SUMs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Conditional Formatting&lt;/strong&gt; that turns overspending red.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Step 1: A workbook and the data
&lt;/h2&gt;

&lt;p&gt;On the Excel start page (microsoft365.com), click &lt;strong&gt;Create blank workbook&lt;/strong&gt;. New files are called "Book"; click the file name at the top and type &lt;code&gt;Bakery budget, October&lt;/code&gt;, then press Enter. Excel for the web saves as you go, so there is no Save button to forget.&lt;/p&gt;

&lt;p&gt;Click &lt;strong&gt;A1&lt;/strong&gt; and type the headers &lt;strong&gt;Category&lt;/strong&gt;, &lt;strong&gt;Budget&lt;/strong&gt; and &lt;strong&gt;Actual&lt;/strong&gt;, then five rows: Rent, Ingredients, Wages, Utilities and Marketing with your numbers.&lt;/p&gt;

&lt;p&gt;Type numbers without commas or a &lt;code&gt;$&lt;/code&gt; sign. You format them as money at the end; typed symbols can turn numbers into text.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Make it a table
&lt;/h2&gt;

&lt;p&gt;Click any cell in the data, then on the &lt;strong&gt;Home&lt;/strong&gt; tab click &lt;strong&gt;Format As Table&lt;/strong&gt; and pick a style (any one works). Excel proposes the range &lt;code&gt;A1:C6&lt;/code&gt;. Check &lt;strong&gt;My table has headers&lt;/strong&gt; is ticked and click &lt;strong&gt;OK&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Every header now has a filter arrow. More importantly, the table is a named object: formulas and totals that refer to it expand when you add rows.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: A Difference column that fills itself
&lt;/h2&gt;

&lt;p&gt;Click &lt;strong&gt;D1&lt;/strong&gt;, type &lt;code&gt;Difference&lt;/code&gt; and press Enter. The table grows to include column D automatically.&lt;/p&gt;

&lt;p&gt;In &lt;strong&gt;D2&lt;/strong&gt; type:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;=C2-B2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Actual minus budget, so a &lt;strong&gt;positive number means overspent&lt;/strong&gt;. Press Enter. Because you are inside a table, Excel copies the formula down the whole column. This is a &lt;em&gt;calculated column&lt;/em&gt;: one formula, applied to every row, including rows you add later.&lt;/p&gt;

&lt;p&gt;Tom's column fills with:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Category&lt;/th&gt;
&lt;th&gt;Difference&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Rent&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Ingredients&lt;/td&gt;
&lt;td&gt;360&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Wages&lt;/td&gt;
&lt;td&gt;-150&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Utilities&lt;/td&gt;
&lt;td&gt;62&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Marketing&lt;/td&gt;
&lt;td&gt;-120&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The sign convention matters. Pick one (actual minus budget here), write it in the header or a note, and stick with it, or the red flags in Step 5 point the wrong way.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: Totals with the Total Row
&lt;/h2&gt;

&lt;p&gt;With a cell in the table selected, open the &lt;strong&gt;Table Design&lt;/strong&gt; tab (it only shows while you are in the table) and tick &lt;strong&gt;Total Row&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;A Total row appears and already sums the last column: &lt;strong&gt;152&lt;/strong&gt;. Budget and Actual are empty. Click &lt;strong&gt;B7&lt;/strong&gt;, click the small arrow next to it, and choose &lt;strong&gt;Sum&lt;/strong&gt;. Do the same in &lt;strong&gt;C7&lt;/strong&gt;. The menu also offers None, Average, Count, Max and Min.&lt;/p&gt;

&lt;p&gt;Result: Budget &lt;strong&gt;16450&lt;/strong&gt;, Actual &lt;strong&gt;16602&lt;/strong&gt;, Difference &lt;strong&gt;152&lt;/strong&gt;, so the month came in $152 over.&lt;/p&gt;

&lt;p&gt;Why not just type &lt;code&gt;=SUM(B2:B6)&lt;/code&gt;? The Total Row uses &lt;code&gt;SUBTOTAL&lt;/code&gt; over the table column, so it follows the table when rows are added and respects filters: filter to one category and the total shows just that category.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 5: Turn overspending red
&lt;/h2&gt;

&lt;p&gt;Select the Difference cells &lt;strong&gt;D2:D6&lt;/strong&gt;. On the &lt;strong&gt;Home&lt;/strong&gt; tab click &lt;strong&gt;Conditional Formatting&lt;/strong&gt; &amp;gt; &lt;strong&gt;Highlight Cell Rules&lt;/strong&gt; &amp;gt; &lt;strong&gt;Greater Than...&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In Excel for the web this opens a &lt;strong&gt;Conditional Formatting panel&lt;/strong&gt; on the right, not a dialog. It already applies to &lt;code&gt;D2:D6&lt;/code&gt; and says &lt;em&gt;Cell value&lt;/em&gt;, &lt;em&gt;Greater than&lt;/em&gt;. Type &lt;code&gt;0&lt;/code&gt; in the value box. The first format style (light red fill) is already picked. Click &lt;strong&gt;Done&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Ingredients (360) and Utilities (62) turn red. Wages and Marketing came in under, so they stay plain. The rule in plain terms:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Applies to: D2:D6
Rule:       Cell value &amp;gt; 0
Format:     light red fill
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 6: Format as money and share
&lt;/h2&gt;

&lt;p&gt;Close the panel, select &lt;strong&gt;B2:D7&lt;/strong&gt;, open the number format box (it says &lt;em&gt;General&lt;/em&gt;) and choose &lt;strong&gt;Currency&lt;/strong&gt;. Totals now read &lt;strong&gt;$16,450.00&lt;/strong&gt;, &lt;strong&gt;$16,602.00&lt;/strong&gt; and &lt;strong&gt;$152.00&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Click &lt;strong&gt;Share&lt;/strong&gt; at the top right, then &lt;strong&gt;Share&lt;/strong&gt; (Copy Link makes a link with default access instead). Type your bookkeeper's email in &lt;em&gt;Add a name, group, or email&lt;/em&gt;, click the eye button and choose &lt;strong&gt;Can edit&lt;/strong&gt; (Can view only reads), then &lt;strong&gt;Send&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Checklist
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;[ ] Numbers typed without &lt;code&gt;$&lt;/code&gt; or commas&lt;/li&gt;
&lt;li&gt;[ ] Data formatted as a table, range &lt;code&gt;A1:C6&lt;/code&gt;, &lt;em&gt;My table has headers&lt;/em&gt; ticked&lt;/li&gt;
&lt;li&gt;[ ] &lt;code&gt;=C2-B2&lt;/code&gt; in D2 filled the whole column on its own&lt;/li&gt;
&lt;li&gt;[ ] Sign convention: positive = over budget&lt;/li&gt;
&lt;li&gt;[ ] Total Row on, with &lt;strong&gt;Sum&lt;/strong&gt; chosen for Budget and Actual&lt;/li&gt;
&lt;li&gt;[ ] Greater Than 0 rule on &lt;code&gt;D2:D6&lt;/code&gt; with light red fill&lt;/li&gt;
&lt;li&gt;[ ] B2:D7 formatted as Currency&lt;/li&gt;
&lt;li&gt;[ ] Shared with &lt;strong&gt;Can edit&lt;/strong&gt; for the bookkeeper, &lt;strong&gt;Can view&lt;/strong&gt; for everyone else&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Where to go next
&lt;/h2&gt;

&lt;p&gt;Once a sheet is a table, the same habits carry into everything else: filters that don't break totals, columns that fill themselves, and rules that flag problems instead of making someone scan for them.&lt;/p&gt;

&lt;p&gt;The full lesson is a 26-step practice copy of the real Excel for the web screens that checks each click, with no Microsoft account needed: &lt;a href="https://ynteractive.com/content/excel-web-budget" rel="noopener noreferrer"&gt;Excel for the Web: Your First Budget Spreadsheet&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>excel</category>
      <category>spreadsheets</category>
      <category>productivity</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Excel #N/A, #VALUE!, #DIV/0! and #REF!: Fix the Cause, Not the Symptom (and Why IFNA Beats IFERROR)</title>
      <dc:creator>Robert Breen</dc:creator>
      <pubDate>Wed, 25 Nov 2026 19:00:00 +0000</pubDate>
      <link>https://dev.to/robert_breen_d96e41ecd765/excel-na-value-div0-and-ref-fix-the-cause-not-the-symptom-and-why-ifna-beats-iferror-2n65</link>
      <guid>https://dev.to/robert_breen_d96e41ecd765/excel-na-value-div0-and-ref-fix-the-cause-not-the-symptom-and-why-ifna-beats-iferror-2n65</guid>
      <description>&lt;p&gt;Excel errors tend to show up the day before invoices go out. The quick fix you find online is to wrap everything in &lt;code&gt;IFERROR&lt;/code&gt;. The sheet looks clean, and the total is wrong.&lt;/p&gt;

&lt;p&gt;This post walks through a made-up October billing workbook for Ridgeway Architects with five errors in it, the actual cause of each, and a safer lookup formula. The diagnosis was done with ChatGPT from a plain-text note describing every cell and formula, but the fixes are plain Excel, and you should check every one in your own workbook.&lt;/p&gt;

&lt;h2&gt;
  
  
  The workbook
&lt;/h2&gt;

&lt;p&gt;Three sheets: &lt;strong&gt;Rates&lt;/strong&gt; (project code and hourly rate), &lt;strong&gt;Timesheet&lt;/strong&gt; (project code, hours, rate lookup, amount) and &lt;strong&gt;Summary&lt;/strong&gt;. Five cells are broken:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Cell&lt;/th&gt;
&lt;th&gt;Error&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Timesheet D3&lt;/td&gt;
&lt;td&gt;&lt;code&gt;#N/A&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Timesheet E4&lt;/td&gt;
&lt;td&gt;&lt;code&gt;#VALUE!&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Timesheet D5&lt;/td&gt;
&lt;td&gt;&lt;code&gt;#N/A&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Timesheet E10&lt;/td&gt;
&lt;td&gt;&lt;code&gt;#DIV/0!&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Summary B2&lt;/td&gt;
&lt;td&gt;&lt;code&gt;#REF!&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  The prompt that gets causes, not cover-ups
&lt;/h2&gt;

&lt;p&gt;Give the AI the real cells and formulas (a note or a screenshot), use a Temporary Chat for business data, and say explicitly that you do not want errors hidden:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;The attached note describes my billing workbook and the errors in it. I'm an office manager, not an Excel expert. For each error (#N/A in D3, #VALUE! in E4, #N/A in D5, #DIV/0! in E10, #REF! on the Summary sheet), tell me in plain words what it means, what caused it in this sheet, and the right fix. Fix the cause, don't just hide the error. Then tell me in what order to fix them.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Without "fix the cause, don't just hide the error", the easy answer is IFERROR everywhere.&lt;/p&gt;

&lt;h2&gt;
  
  
  Each error and its real cause
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;#N/A in D3: a trailing space.&lt;/strong&gt; The lookup is looking for the project code in B3, but B3 has a space after the code, so it matches nothing in Rates. Fix: remove the space (and make the formula immune to it, below).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;#VALUE! in E4: text where a number should be.&lt;/strong&gt; C4 says &lt;code&gt;7.5 hrs&lt;/code&gt;. Excel cannot multiply words. Fix: type &lt;code&gt;7.5&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;#N/A in D5: a genuinely missing rate.&lt;/strong&gt; Project RW-105 is not on the Rates sheet. The right fix is to add the real rate. The answer said, in so many words, do not guess the rate.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;#DIV/0! in E10: dividing by zero or an empty cell.&lt;/strong&gt; Decide what that cell should show when there is nothing to divide, such as "No activity", rather than forcing a zero.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;#REF! on Summary B2: a deleted column.&lt;/strong&gt; The formula pointed at a cell that no longer exists. Fix: point it at the right cell again, here &lt;code&gt;=Timesheet!E8&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  The bonus catch
&lt;/h3&gt;

&lt;p&gt;Nobody asked about it, but E10 is labeled &lt;em&gt;Share billed to RW-106&lt;/em&gt; while its formula works out an average rate, not a share. A label and a formula that disagree are a bug even when no error shows. Ask whoever built the sheet which one they meant.&lt;/p&gt;

&lt;h2&gt;
  
  
  A total you can defend
&lt;/h2&gt;

&lt;p&gt;Second prompt:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Good. Now two things. 1) Once those are fixed, what should Total billed in E8 be? Show the arithmetic line by line so I can check it, and tell me which row you cannot total and why. 2) Give me a safer version of the D2 formula I can copy down so a trailing space never breaks it again and a missing project code shows "Add rate" instead of an error. Explain what each part does.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The arithmetic came back line by line, with RW-105 left out because its rate is unknown:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1,072.50 + 1,120.00 + 1,387.50 + 750.00 = 4,330.00
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check it yourself. One row: 6.5 hours x $165 = $1,072.50. The hours add to 27 without row 5, 31 with it. The answer also used $160 and $150 as example rates in places: those are illustrations, not rates. Do not bill from them.&lt;/p&gt;

&lt;h2&gt;
  
  
  The safer lookup
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;=IFNA(VLOOKUP(TRIM(B2),Rates!A:B,2,FALSE),"Add rate")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;TRIM(B2)&lt;/code&gt; strips stray spaces, so B3 finds its rate.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;VLOOKUP(..., Rates!A:B, 2, FALSE)&lt;/code&gt; is an exact-match lookup of the code in column A, returning the rate in column B.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;IFNA(..., "Add rate")&lt;/code&gt; replaces only the &lt;em&gt;not found&lt;/em&gt; error.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Why IFNA and not IFERROR
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;IFERROR&lt;/code&gt; hides every error, including a &lt;code&gt;#REF!&lt;/code&gt; from a deleted range or a &lt;code&gt;#VALUE!&lt;/code&gt; from bad input. &lt;code&gt;IFNA&lt;/code&gt; handles exactly one case, a missing match, and lets every other problem stay visible. That is what you want in a billing sheet.&lt;/p&gt;

&lt;p&gt;After the change, E5 still shows &lt;code&gt;#VALUE!&lt;/code&gt;, because it cannot multiply 4 hours by the words "Add rate". That is a warning, not a bug. Do not type a zero just to make E8 add up; get the real rate before invoicing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Order of operations
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Fix the data: remove the trailing space, replace &lt;code&gt;7.5 hrs&lt;/code&gt; with &lt;code&gt;7.5&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Repoint Summary B2 to &lt;code&gt;=Timesheet!E8&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Replace the D2 lookup with the TRIM + IFNA version and copy it down.&lt;/li&gt;
&lt;li&gt;Decide what E10 should show, and whether it should be a share or an average.&lt;/li&gt;
&lt;li&gt;Get RW-105's real rate. Until then, E5 and the total stay visibly incomplete.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Checklist
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;[ ] Gave the AI the real cells and formulas, not a vague description&lt;/li&gt;
&lt;li&gt;[ ] Asked it to fix causes, not hide errors&lt;/li&gt;
&lt;li&gt;[ ] Checked the subtotal by hand ($4,330.00 for the four known rows)&lt;/li&gt;
&lt;li&gt;[ ] Treated example rates as examples, not billable numbers&lt;/li&gt;
&lt;li&gt;[ ] Used &lt;code&gt;IFNA&lt;/code&gt; for the lookup, not a blanket &lt;code&gt;IFERROR&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;[ ] Checked that labels match what the formulas compute&lt;/li&gt;
&lt;li&gt;[ ] Pasted the formulas into your own copy and confirmed D3 shows 140 and D5 shows Add rate&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One honest note from the lesson: the formulas were not pasted into a real Excel workbook for it. Rebuild the sheets from the downloadable note, paste them in, and check the results yourself.&lt;/p&gt;

&lt;p&gt;The full walkthrough, with the billing note to download and a 19-step practice copy of ChatGPT, is here: &lt;a href="https://ynteractive.com/content/chatgpt-fix-excel-formula-errors" rel="noopener noreferrer"&gt;ChatGPT: Fix #N/A, #VALUE!, #DIV/0! and #REF! Errors in Excel&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>excel</category>
      <category>spreadsheets</category>
      <category>productivity</category>
      <category>ai</category>
    </item>
    <item>
      <title>n8n Items and Expressions: Five Invoices In, Five Reminders Out (Pinned Mock Data, $json and .round(2))</title>
      <dc:creator>Robert Breen</dc:creator>
      <pubDate>Wed, 25 Nov 2026 16:00:00 +0000</pubDate>
      <link>https://dev.to/robert_breen_d96e41ecd765/n8n-items-and-expressions-five-invoices-in-five-reminders-out-pinned-mock-data-json-and-3po1</link>
      <guid>https://dev.to/robert_breen_d96e41ecd765/n8n-items-and-expressions-five-invoices-in-five-reminders-out-pinned-mock-data-json-and-3po1</guid>
      <description>&lt;p&gt;Most people who get stuck in n8n are not stuck on a node. They are stuck on the data between nodes: what an "item" is, why &lt;code&gt;{{ $json.client }}&lt;/code&gt; sometimes works and sometimes shows nothing, and why a simple percentage turns into &lt;code&gt;15.200000000000001&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;This walkthrough fixes that with one small example. A made-up bookkeeping firm, Clearview Bookkeeping, has five overdue invoices and writes every reminder by hand. Before automating the email, you need to see how n8n holds the data. You will:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Pin five fake invoices on a manual trigger, no real app connected.&lt;/li&gt;
&lt;li&gt;Read them as Schema, Table and JSON.&lt;/li&gt;
&lt;li&gt;Build one Edit Fields (Set) node that produces a reminder sentence, an email field and a 2% late fee for every invoice.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Step 1: Give the trigger test data with "set mock data"
&lt;/h2&gt;

&lt;p&gt;Start an empty workflow, click &lt;strong&gt;Add first step...&lt;/strong&gt;, and choose &lt;strong&gt;Trigger manually&lt;/strong&gt;. While you are learning, a button is the easiest way to start.&lt;/p&gt;

&lt;p&gt;Open the trigger (it sits on the canvas as &lt;em&gt;When clicking 'Execute workflow'&lt;/em&gt;). It has no parameters and the OUTPUT says &lt;em&gt;No trigger output&lt;/em&gt;. Instead of connecting a real system, click &lt;strong&gt;set mock data&lt;/strong&gt;. The EDIT OUTPUT box holds an example; replace it with this list and click &lt;strong&gt;Save&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;[&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"client"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"Lakeside Dental"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"email"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"billing@lakeside-dental.example"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"invoice"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"INV-1042"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"amount"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;480&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"days_late"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"client"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"Northpoint Realty"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"email"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"ap@northpoint.example"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"invoice"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"INV-1045"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"amount"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;1250&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"days_late"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;34&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"client"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"Brightline Studio"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"email"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"hello@brightline.example"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"invoice"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"INV-1047"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"amount"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;300&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"days_late"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"client"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"Cedar &amp;amp; Vine Law"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"email"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"office@cedarvine.example"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"invoice"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"INV-1051"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"amount"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;2100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"days_late"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;48&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"client"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"Harbor Lane Marketing"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"email"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"finance@harborlane.example"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"invoice"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"INV-1053"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"amount"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;760&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"days_late"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;19&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A list in square brackets, one pair of curly brackets per invoice. The email addresses use &lt;code&gt;.example&lt;/code&gt; domains, so nothing can be sent by accident.&lt;/p&gt;

&lt;p&gt;After saving, a banner reads &lt;strong&gt;This data is pinned for test executions&lt;/strong&gt;, and the OUTPUT says &lt;strong&gt;5 items&lt;/strong&gt;. Test runs now reuse this data instead of calling a real app, which is also how you avoid burning API calls while building.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: One item per record, read three ways
&lt;/h2&gt;

&lt;p&gt;n8n passes a &lt;strong&gt;list of items&lt;/strong&gt; between nodes. Each item is one record with named fields, and most nodes run once per item: 5 invoices in, 5 results out.&lt;/p&gt;

&lt;p&gt;Switch the OUTPUT view to see the same items three ways:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Schema&lt;/strong&gt; shows the fields of one item.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Table&lt;/strong&gt; shows five rows, one per invoice. Text fields carry a &lt;code&gt;T&lt;/code&gt;, numbers a &lt;code&gt;#&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;JSON&lt;/strong&gt; shows the raw data, exactly as you pasted it. Almost every app sends data to n8n in this shape.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Close the node. The pin icon on the trigger reminds you it is using pinned data.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Write expressions by dragging
&lt;/h2&gt;

&lt;p&gt;Click the &lt;strong&gt;+&lt;/strong&gt; after the trigger, type &lt;code&gt;Edit&lt;/code&gt;, and pick &lt;strong&gt;Edit Fields (Set)&lt;/strong&gt;. The INPUT panel shows 5 items and the fields of the first one.&lt;/p&gt;

&lt;p&gt;Click &lt;strong&gt;Add Field&lt;/strong&gt;, name it &lt;code&gt;reminder&lt;/code&gt;, then drag &lt;code&gt;client&lt;/code&gt; from INPUT onto the value box. n8n writes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jinja"&gt;&lt;code&gt;&lt;span class="cp"&gt;{{&lt;/span&gt; &lt;span class="nv"&gt;$json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;client&lt;/span&gt; &lt;span class="cp"&gt;}}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;$json&lt;/code&gt; means &lt;em&gt;this item's data&lt;/em&gt;, so the expression reads "this item's client". Now type &lt;code&gt;is&lt;/code&gt; (a space each side), drag in &lt;code&gt;days_late&lt;/code&gt;, and finish with &lt;code&gt;days late&lt;/code&gt;. The value becomes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jinja"&gt;&lt;code&gt;&lt;span class="cp"&gt;{{&lt;/span&gt; &lt;span class="nv"&gt;$json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;client&lt;/span&gt; &lt;span class="cp"&gt;}}&lt;/span&gt; is &lt;span class="cp"&gt;{{&lt;/span&gt; &lt;span class="nv"&gt;$json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;days_late&lt;/span&gt; &lt;span class="cp"&gt;}}&lt;/span&gt; days late
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The Result line under the field shows &lt;strong&gt;Lakeside Dental is 12 days late&lt;/strong&gt; for &lt;em&gt;Item 0&lt;/em&gt;. Click the &lt;strong&gt;›&lt;/strong&gt; next to it to preview Item 1: &lt;strong&gt;Northpoint Realty is 34 days late&lt;/strong&gt;. One expression, a different answer for every item. That is the whole idea of items.&lt;/p&gt;

&lt;h3&gt;
  
  
  Shortcut: drop a whole field
&lt;/h3&gt;

&lt;p&gt;Drag &lt;code&gt;email&lt;/code&gt; onto the &lt;strong&gt;Drag input fields here&lt;/strong&gt; area. n8n creates a field named &lt;code&gt;email&lt;/code&gt; with the value &lt;code&gt;{{ $json.email }}&lt;/code&gt; in one move. Use this when you want to carry a field through unchanged.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: A calculated field, and the two gotchas
&lt;/h2&gt;

&lt;p&gt;Click &lt;strong&gt;Add Field&lt;/strong&gt; again and name it &lt;code&gt;late_fee&lt;/code&gt;. A fee is a number, so open the type box (it says &lt;em&gt;String&lt;/em&gt;) and choose &lt;strong&gt;Number&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Gotcha 1: a Number box only takes digits.&lt;/strong&gt; If you type a &lt;code&gt;{{ }}&lt;/code&gt; formula straight into it, the field strips everything that is not a digit and mangles it. Point at the value and click &lt;strong&gt;Expression&lt;/strong&gt; first, then paste:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight liquid"&gt;&lt;code&gt;&lt;span class="cp"&gt;{{&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;amount&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mf"&gt;0.02&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;round&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="cp"&gt;}}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Anything inside &lt;code&gt;{{ }}&lt;/code&gt; is JavaScript, so this is 2% of the amount.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Gotcha 2: floating point.&lt;/strong&gt; Without &lt;code&gt;.round(2)&lt;/code&gt;, Harbor Lane's &lt;code&gt;760 * 0.02&lt;/code&gt; shows as &lt;code&gt;15.200000000000001&lt;/code&gt;. Computers store decimals in binary, so some results carry a long tail. &lt;code&gt;.round(2)&lt;/code&gt; rounds to cents.&lt;/p&gt;

&lt;p&gt;Click &lt;strong&gt;Execute step&lt;/strong&gt;. You get 5 items in and 5 items out, each with its own &lt;code&gt;reminder&lt;/code&gt;, &lt;code&gt;email&lt;/code&gt; and &lt;code&gt;late_fee&lt;/code&gt;. The fees come out as:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;invoice&lt;/th&gt;
&lt;th&gt;amount&lt;/th&gt;
&lt;th&gt;late_fee&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;INV-1042&lt;/td&gt;
&lt;td&gt;480&lt;/td&gt;
&lt;td&gt;9.6&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;INV-1045&lt;/td&gt;
&lt;td&gt;1250&lt;/td&gt;
&lt;td&gt;25&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;INV-1047&lt;/td&gt;
&lt;td&gt;300&lt;/td&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;INV-1051&lt;/td&gt;
&lt;td&gt;2100&lt;/td&gt;
&lt;td&gt;42&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;INV-1053&lt;/td&gt;
&lt;td&gt;760&lt;/td&gt;
&lt;td&gt;15.2&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  What the output looks like as JSON
&lt;/h2&gt;

&lt;p&gt;Switch the Edit Fields OUTPUT to JSON and the first item looks like this (shape only; your field order may differ, and Edit Fields keeps only the fields you set unless you include the others):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"reminder"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Lakeside Dental is 12 days late"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"email"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"billing@lakeside-dental.example"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"late_fee"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;9.6&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That is a clean record, ready for a Gmail or Slack node downstream, which will also run once per item.&lt;/p&gt;

&lt;h2&gt;
  
  
  Checklist
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;[ ] Trigger has pinned mock data and the banner says &lt;em&gt;This data is pinned for test executions&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;[ ] OUTPUT shows &lt;strong&gt;5 items&lt;/strong&gt; in Table view&lt;/li&gt;
&lt;li&gt;[ ] &lt;code&gt;reminder&lt;/code&gt; uses &lt;code&gt;{{ $json.client }}&lt;/code&gt; and &lt;code&gt;{{ $json.days_late }}&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;[ ] Result preview checked on Item 0 and Item 1 with &lt;strong&gt;›&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;[ ] &lt;code&gt;email&lt;/code&gt; added by dropping the field onto &lt;em&gt;Drag input fields here&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;[ ] &lt;code&gt;late_fee&lt;/code&gt; is type Number, switched to &lt;strong&gt;Expression&lt;/strong&gt; before typing&lt;/li&gt;
&lt;li&gt;[ ] &lt;code&gt;.round(2)&lt;/code&gt; on the fee, so 760 gives 15.2, not 15.200000000000001&lt;/li&gt;
&lt;li&gt;[ ] &lt;strong&gt;Execute step&lt;/strong&gt; returns 5 items in, 5 out&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Quick FAQ
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What is an item in n8n?&lt;/strong&gt; One record, such as one invoice or one form submission, with named fields. Nodes pass lists of items and usually run once per item.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What does &lt;code&gt;$json&lt;/code&gt; mean?&lt;/strong&gt; The current item's data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How do I test without connecting an app?&lt;/strong&gt; Open the trigger, click &lt;strong&gt;set mock data&lt;/strong&gt;, paste JSON, save. Test runs use the pinned data.&lt;/p&gt;

&lt;p&gt;The full lesson, with a practice copy of the n8n editor that checks each of the 28 steps as you do them, is here: &lt;a href="https://ynteractive.com/content/n8n-items-json-expressions-tutorial" rel="noopener noreferrer"&gt;n8n: Items, JSON and Expressions, Explained by Doing&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>n8n</category>
      <category>automation</category>
      <category>javascript</category>
      <category>lowcode</category>
    </item>
    <item>
      <title>JavaScript: Build an Instant Quote Calculator With a Minimum Charge in Four Lines of HTML and Math.max</title>
      <dc:creator>Robert Breen</dc:creator>
      <pubDate>Tue, 24 Nov 2026 22:00:00 +0000</pubDate>
      <link>https://dev.to/robert_breen_d96e41ecd765/javascript-build-an-instant-quote-calculator-with-a-minimum-charge-in-four-lines-of-html-and-jd4</link>
      <guid>https://dev.to/robert_breen_d96e41ecd765/javascript-build-an-instant-quote-calculator-with-a-minimum-charge-in-four-lines-of-html-and-jd4</guid>
      <description>&lt;p&gt;A small office-cleaning business gets the same enquiry every day: "How much for our office?" Then an email back asking for the size, then a reply with a price a day later, by which time half the people have asked someone else.&lt;/p&gt;

&lt;p&gt;The pricing rule is simple: &lt;strong&gt;12 cents a square foot, never less than $150.&lt;/strong&gt; That rule fits in one line of JavaScript, and the whole calculator fits on one page. This post builds it in &lt;a href="https://jsfiddle.net" rel="noopener noreferrer"&gt;JSFiddle&lt;/a&gt;, the free code playground, with no account needed.&lt;/p&gt;

&lt;h2&gt;
  
  
  What you build
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;2,000 square feet gives &lt;strong&gt;Estimate: $240.00&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;800 square feet gives &lt;strong&gt;Estimate: $150.00&lt;/strong&gt; (the minimum)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Change the rate or the minimum and every quote follows.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: The form (HTML panel)
&lt;/h2&gt;

&lt;p&gt;Four lines: a heading, a number box, a button and an empty paragraph for the result.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;h3&amp;gt;&lt;/span&gt;Office cleaning quote&lt;span class="nt"&gt;&amp;lt;/h3&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"sqft"&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"number"&lt;/span&gt; &lt;span class="na"&gt;placeholder&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Square feet"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"quote-btn"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Get my quote&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"result"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;id&lt;/code&gt; values matter. They're how JavaScript finds each element.&lt;/p&gt;

&lt;p&gt;JSFiddle often adds closing tags for you as you type. If you end up with a doubled &lt;code&gt;&amp;lt;/h3&amp;gt;&lt;/code&gt; or a stray &lt;code&gt;&amp;gt;&lt;/code&gt;, delete it.&lt;/p&gt;

&lt;p&gt;Click &lt;strong&gt;Run&lt;/strong&gt; at the top. The Result panel shows the form. The button does nothing yet.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: The price rule (JavaScript panel)
&lt;/h2&gt;

&lt;p&gt;Put the two numbers your price depends on at the top, as constants:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;RATE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.12&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;     &lt;span class="c1"&gt;// dollars per square foot&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;MINIMUM&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;150&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   &lt;span class="c1"&gt;// smallest job we take&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Everything after &lt;code&gt;//&lt;/code&gt; is a note for people; the browser ignores it.&lt;/p&gt;

&lt;p&gt;Now a function that prices a job:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;quote&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sqft&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sqft&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="no"&gt;RATE&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;MINIMUM&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Math.max&lt;/code&gt; returns the bigger of its arguments. For 2,000 square feet, &lt;code&gt;2000 * 0.12&lt;/code&gt; is 240, which beats 150, so you get 240. For 800 square feet, &lt;code&gt;800 * 0.12&lt;/code&gt; is 96, which loses to 150, so you get 150. No &lt;code&gt;if&lt;/code&gt; statement needed; the minimum charge is built into one expression.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Connect the button
&lt;/h2&gt;

&lt;p&gt;Three lines find the page parts by their ids:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;button&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'#quote-btn'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;box&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'#sqft'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'#result'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, when the button is clicked: read the box, price it, and write the estimate with two decimals.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="n"&gt;button&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;onclick&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;quote&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;box&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;textContent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'Estimate: $'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toFixed&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two details:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;box.value&lt;/code&gt; is always a &lt;strong&gt;string&lt;/strong&gt;, even in a number input. &lt;code&gt;Number(...)&lt;/code&gt; turns it into a number before the multiplication.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;toFixed(2)&lt;/code&gt; turns &lt;code&gt;240&lt;/code&gt; into &lt;code&gt;"240.00"&lt;/code&gt; and &lt;code&gt;150&lt;/code&gt; into &lt;code&gt;"150.00"&lt;/code&gt;, so a price always shows cents.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Point at the JavaScript panel and a small &lt;strong&gt;tidy&lt;/strong&gt; icon appears at its top right. Click it and JSFiddle indents the code. Nothing changes in how it works; it's just easier to read.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: Test both paths
&lt;/h2&gt;

&lt;p&gt;Click &lt;strong&gt;Run&lt;/strong&gt;, then in the Result panel:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Type &lt;code&gt;2000&lt;/code&gt; and click &lt;strong&gt;Get my quote&lt;/strong&gt;. You should see &lt;code&gt;Estimate: $240.00&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Select the number, type &lt;code&gt;800&lt;/code&gt;, and click &lt;strong&gt;Get my quote&lt;/strong&gt; again. You should see &lt;code&gt;Estimate: $150.00&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Always test one case on each side of the minimum. If the small office comes out at &lt;code&gt;$96.00&lt;/code&gt;, &lt;code&gt;Math.max&lt;/code&gt; isn't in the path; if every quote is &lt;code&gt;$150.00&lt;/code&gt;, the box value probably isn't reaching &lt;code&gt;quote()&lt;/code&gt; as a number.&lt;/p&gt;

&lt;h2&gt;
  
  
  The full JavaScript
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;RATE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.12&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;     &lt;span class="c1"&gt;// dollars per square foot&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;MINIMUM&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;150&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   &lt;span class="c1"&gt;// smallest job we take&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;quote&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sqft&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sqft&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="no"&gt;RATE&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;MINIMUM&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;button&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'#quote-btn'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;box&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'#sqft'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'#result'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="n"&gt;button&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;onclick&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;quote&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;box&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;textContent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'Estimate: $'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toFixed&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Why this shape works
&lt;/h2&gt;

&lt;p&gt;Keeping the rule in one small function pays off as the pricing changes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The price lives in two constants.&lt;/strong&gt; If the rate goes to 14 cents, you change &lt;code&gt;RATE&lt;/code&gt; and nothing else. Nobody has to hunt through the click handler for a magic number.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;quote()&lt;/code&gt; knows nothing about the page.&lt;/strong&gt; It takes a number and returns a number. You can test it in the browser console with &lt;code&gt;quote(2000)&lt;/code&gt; and &lt;code&gt;quote(800)&lt;/code&gt; without touching the form at all.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The click handler only does wiring.&lt;/strong&gt; Read the input, call the rule, write the output. If you later add a second input (say, visits per week), the handler grows by one line and the rule stays readable.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That separation is the difference between a calculator you can maintain and one you're afraid to edit.&lt;/p&gt;

&lt;h2&gt;
  
  
  Checklist
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;[ ] Four HTML lines with ids &lt;code&gt;sqft&lt;/code&gt;, &lt;code&gt;quote-btn&lt;/code&gt; and &lt;code&gt;result&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;[ ] &lt;code&gt;RATE&lt;/code&gt; and &lt;code&gt;MINIMUM&lt;/code&gt; as constants at the top, so a price change is a one-line edit&lt;/li&gt;
&lt;li&gt;[ ] &lt;code&gt;Math.max(sqft * RATE, MINIMUM)&lt;/code&gt; for the minimum charge&lt;/li&gt;
&lt;li&gt;[ ] &lt;code&gt;Number(box.value)&lt;/code&gt; before doing math on the input&lt;/li&gt;
&lt;li&gt;[ ] &lt;code&gt;toFixed(2)&lt;/code&gt; on the displayed price&lt;/li&gt;
&lt;li&gt;[ ] Tested above the minimum (2,000 → $240.00) and below it (800 → $150.00)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The same HTML and JavaScript can go on a real website: whoever manages the site can paste both into a page.&lt;/p&gt;

&lt;h2&gt;
  
  
  Practice it
&lt;/h2&gt;

&lt;p&gt;If you'd like to type it line by line with each step checked (13 steps, about 12 minutes, free), the interactive version is here: &lt;a href="https://learn.ynteractive.com/content/js-quote-calculator" rel="noopener noreferrer"&gt;JavaScript: An Instant Quote Calculator for Your Website&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>webdev</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>n8n Execute Step vs Execute Workflow vs Publish: Why It Works in the Editor but Not From Your Form</title>
      <dc:creator>Robert Breen</dc:creator>
      <pubDate>Tue, 24 Nov 2026 19:00:00 +0000</pubDate>
      <link>https://dev.to/robert_breen_d96e41ecd765/n8n-execute-step-vs-execute-workflow-vs-publish-why-it-works-in-the-editor-but-not-from-your-form-4k9p</link>
      <guid>https://dev.to/robert_breen_d96e41ecd765/n8n-execute-step-vs-execute-workflow-vs-publish-why-it-works-in-the-editor-but-not-from-your-form-4k9p</guid>
      <description>&lt;p&gt;"It works in the editor but not for real" is probably the most common n8n complaint, and it is almost always the same thing: mixing up three buttons that do three different jobs.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Execute step&lt;/strong&gt; runs one node.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Execute workflow&lt;/strong&gt; runs every node from the trigger onward.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Publish&lt;/strong&gt; makes the workflow live.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This post uses a small, already-built workflow for a bookkeeping office to show what each one actually does, plus the pinned-data trick that stops you resending a test form twenty times.&lt;/p&gt;

&lt;h2&gt;
  
  
  The workflow
&lt;/h2&gt;

&lt;p&gt;Three nodes:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Webhook&lt;/strong&gt;: catches a new-client form from the website.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Edit Fields&lt;/strong&gt;: picks out the email and name.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Append row in sheet&lt;/strong&gt; (Google Sheets): adds a row to a New clients sheet with the headers &lt;code&gt;Email&lt;/code&gt;, &lt;code&gt;Name&lt;/code&gt;, &lt;code&gt;Service&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The form posts three fields, and they arrive inside &lt;code&gt;body&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"body"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Dana Ortiz"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"email"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"dana@ortizdesign.com"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"service"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Monthly bookkeeping"&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So in later nodes the email is &lt;code&gt;{{ $json.body.email }}&lt;/code&gt;, not &lt;code&gt;{{ $json.email }}&lt;/code&gt;. That one detail causes a lot of empty columns.&lt;/p&gt;

&lt;h2&gt;
  
  
  Execute step: run one node
&lt;/h2&gt;

&lt;p&gt;Open &lt;strong&gt;Edit Fields&lt;/strong&gt; and click &lt;strong&gt;Execute step&lt;/strong&gt; at the top of the middle panel. n8n runs that node using the data from the node before it and shows the result in the OUTPUT panel. It is the fastest way to check one change.&lt;/p&gt;

&lt;p&gt;The catch: if the node before it has never run, the INPUT side says &lt;strong&gt;No input data&lt;/strong&gt;. Click Execute step anyway and n8n runs the earlier nodes first. For a Webhook trigger, that means it sits waiting for a test call that isn't coming. Click the stop button (the square next to the spinner) and give the Webhook test data instead.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pin test data so you stop resending the form
&lt;/h2&gt;

&lt;p&gt;Open the &lt;strong&gt;Webhook&lt;/strong&gt; node. Its &lt;strong&gt;Test URL&lt;/strong&gt; only listens while you click &lt;strong&gt;Listen for test event&lt;/strong&gt; in the editor. You don't need a real submission right now:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Click the &lt;strong&gt;pencil&lt;/strong&gt; at the top of the OUTPUT panel.&lt;/li&gt;
&lt;li&gt;Paste a sample submission (the JSON above).&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Save&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The banner reads &lt;strong&gt;This data is pinned for test executions&lt;/strong&gt;. The node shows a pin, and every test run uses that data until you unpin it.&lt;/p&gt;

&lt;p&gt;Now open Edit Fields again and click &lt;strong&gt;Execute step&lt;/strong&gt;. The INPUT side shows the pinned data, only this node runs, and the OUTPUT shows &lt;code&gt;email&lt;/code&gt; and &lt;code&gt;name&lt;/code&gt;, filled in by:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight liquid"&gt;&lt;code&gt;&lt;span class="cp"&gt;{{&lt;/span&gt; &lt;span class="nv"&gt;$json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;email&lt;/span&gt; &lt;span class="cp"&gt;}}&lt;/span&gt;
&lt;span class="cp"&gt;{{&lt;/span&gt; &lt;span class="nv"&gt;$json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="cp"&gt;}}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Execute workflow: run everything, then look at the result
&lt;/h2&gt;

&lt;p&gt;Click &lt;strong&gt;Execute&lt;/strong&gt; at the bottom of the canvas. It runs the whole workflow (the same button appears as &lt;strong&gt;Execute workflow&lt;/strong&gt; when you point at the trigger). Every node gets a green check and each line shows how many items passed.&lt;/p&gt;

&lt;p&gt;Here's the thing people miss: &lt;strong&gt;a green check means the node ran, not that the output is right.&lt;/strong&gt; Open the sheet. In the lesson, row 2 has Dana's email and name in the right columns, which is the real check, but &lt;strong&gt;Service&lt;/strong&gt; is blank. Nothing sends it yet. The green checks didn't tell you that; the sheet did.&lt;/p&gt;

&lt;h2&gt;
  
  
  Publish and the Production URL
&lt;/h2&gt;

&lt;p&gt;Your work is saved, but saving does not turn the workflow on. Real form submissions only run it once it is published.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Click &lt;strong&gt;Publish&lt;/strong&gt; at the top right.&lt;/li&gt;
&lt;li&gt;Open the Webhook node.&lt;/li&gt;
&lt;li&gt;Under &lt;strong&gt;Webhook URLs&lt;/strong&gt;, click &lt;strong&gt;Production URL&lt;/strong&gt; and copy it.&lt;/li&gt;
&lt;li&gt;Paste that into your form's settings.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Compare the two addresses:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Test URL:        https://&amp;lt;your-n8n&amp;gt;/webhook-test/&amp;lt;path&amp;gt;
Production URL:  https://&amp;lt;your-n8n&amp;gt;/webhook/&amp;lt;path&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The production one has &lt;code&gt;/webhook/&lt;/code&gt;, not &lt;code&gt;/webhook-test/&lt;/code&gt;, and works all the time while the workflow is published. If your form is pointing at the &lt;code&gt;-test&lt;/code&gt; address, it only works while someone has the editor open and is listening. That is the "works in the editor, not from my form" bug.&lt;/p&gt;

&lt;h2&gt;
  
  
  Change it, then publish again
&lt;/h2&gt;

&lt;p&gt;Now fix the blank Service column. Open Edit Fields, click &lt;strong&gt;Add Field&lt;/strong&gt; and set:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight liquid"&gt;&lt;code&gt;service = &lt;span class="cp"&gt;{{&lt;/span&gt; &lt;span class="nv"&gt;$json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;service&lt;/span&gt; &lt;span class="cp"&gt;}}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Close the node. The change is saved in the editor, but the &lt;strong&gt;live workflow is still the old version&lt;/strong&gt;. Real submissions still skip the service. &lt;strong&gt;Publish&lt;/strong&gt; lights up again because you have changes that aren't live. Click it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Checklist
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;[ ] Form fields read from &lt;code&gt;$json.body.*&lt;/code&gt;, not &lt;code&gt;$json.*&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;[ ] Sample submission pinned on the Webhook (banner: "This data is pinned for test executions")&lt;/li&gt;
&lt;li&gt;[ ] Execute step used to check single-node changes&lt;/li&gt;
&lt;li&gt;[ ] Execute workflow run, then the actual sheet row checked, not just the green checks&lt;/li&gt;
&lt;li&gt;[ ] Published, with the &lt;strong&gt;Production URL&lt;/strong&gt; (&lt;code&gt;/webhook/&lt;/code&gt;) in the form&lt;/li&gt;
&lt;li&gt;[ ] Published again after every edit&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once real submissions are flowing, set up an error workflow so a failed live run tells you instead of failing quietly.&lt;/p&gt;

&lt;h2&gt;
  
  
  Practice it
&lt;/h2&gt;

&lt;p&gt;You can click through all 25 steps of this in a practice copy of the n8n editor, about 6 minutes, nothing touches your account: &lt;a href="https://learn.ynteractive.com/content/n8n-execute-step-execute-workflow-publish" rel="noopener noreferrer"&gt;How to Activate a Workflow in n8n: Execute Step, Execute Workflow and Publish&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>n8n</category>
      <category>webhooks</category>
      <category>automation</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>n8n Schedule Trigger: Your Monday 8am Workflow Never Ran. Publish It, Then Check the Time Zone</title>
      <dc:creator>Robert Breen</dc:creator>
      <pubDate>Tue, 24 Nov 2026 16:00:00 +0000</pubDate>
      <link>https://dev.to/robert_breen_d96e41ecd765/n8n-schedule-trigger-your-monday-8am-workflow-never-ran-publish-it-then-check-the-time-zone-2lk7</link>
      <guid>https://dev.to/robert_breen_d96e41ecd765/n8n-schedule-trigger-your-monday-8am-workflow-never-ran-publish-it-then-check-the-time-zone-2lk7</guid>
      <description>&lt;p&gt;Every Monday someone at a small consulting firm chases the team for timesheets. When they forget, invoices go out late. That is the job the n8n &lt;strong&gt;Schedule Trigger&lt;/strong&gt; is built for: a workflow that starts by itself at a set time, with nobody clicking anything.&lt;/p&gt;

&lt;p&gt;The trigger is easy to set up. Most of the trouble comes later, when Monday arrives and nothing happens. This post walks through the full build (every Monday at 8am, a timesheet reminder) and the two checks that decide whether it actually fires.&lt;/p&gt;

&lt;h2&gt;
  
  
  What you build
&lt;/h2&gt;

&lt;p&gt;Two nodes:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Schedule Trigger&lt;/strong&gt;: every week, Monday, 8am.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Edit Fields (Set)&lt;/strong&gt;: builds a &lt;code&gt;message&lt;/code&gt; field from the trigger's output.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In a real setup you would add a Gmail or Slack node after it to send the message. The point here is getting the schedule right.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Add the trigger
&lt;/h2&gt;

&lt;p&gt;On an empty canvas, click &lt;strong&gt;Add first step...&lt;/strong&gt; and choose &lt;strong&gt;On a schedule&lt;/strong&gt;. Its description is "Runs the flow every day, hour, or custom interval".&lt;/p&gt;

&lt;p&gt;Read the note at the top of the node. It says the workflow will run on the schedule you define &lt;em&gt;once you publish it&lt;/em&gt;. Keep that sentence in mind; it is the whole of mistake number one below.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Every Monday at 8am
&lt;/h2&gt;

&lt;p&gt;Under &lt;strong&gt;Trigger Rules &amp;gt; Trigger Interval 1&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Open &lt;strong&gt;Trigger Interval&lt;/strong&gt; (it starts on Days). The options run from Seconds, Minutes, Hours, Days, Weeks, Months to Custom (Cron). Pick &lt;strong&gt;Weeks&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Weeks Between Triggers&lt;/strong&gt; stays at &lt;code&gt;1&lt;/code&gt; (every week).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Trigger on Weekdays&lt;/strong&gt; starts with Sunday selected. Click the x on Sunday, open the box and choose &lt;strong&gt;Monday&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Open &lt;strong&gt;Trigger at Hour&lt;/strong&gt; (it says Midnight) and choose &lt;strong&gt;8am&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Trigger at Minute&lt;/strong&gt; stays &lt;code&gt;0&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The settings, all in one place:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Setting&lt;/th&gt;
&lt;th&gt;Value&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Trigger Interval&lt;/td&gt;
&lt;td&gt;Weeks&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Weeks Between Triggers&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Trigger on Weekdays&lt;/td&gt;
&lt;td&gt;Monday&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Trigger at Hour&lt;/td&gt;
&lt;td&gt;8am&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Trigger at Minute&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Timezone (workflow Settings)&lt;/td&gt;
&lt;td&gt;Default - America/New York&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;If you prefer cron, choose &lt;strong&gt;Custom (Cron)&lt;/strong&gt; and type an expression instead. For example, weekdays at 8:30:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;30 8 * * 1-5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 3: Test it without waiting for Monday
&lt;/h2&gt;

&lt;p&gt;Click &lt;strong&gt;Execute step&lt;/strong&gt;. It fires the trigger once, immediately, and outputs one item with fields like the timestamp, Readable date, Day of week, Hour, Minute and Timezone.&lt;/p&gt;

&lt;p&gt;Something to notice: a test run uses the moment you click. In the lesson the test ran on a Saturday, so the output said:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"Day of week"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Saturday"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"Timezone"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"America/New_York"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On Monday at 8 the real run will say Monday. Don't "fix" a test that reports the wrong day; it is reporting the day you tested.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: Build the reminder with an expression
&lt;/h2&gt;

&lt;p&gt;Click the &lt;strong&gt;+&lt;/strong&gt; after the Schedule Trigger, type &lt;code&gt;Edit&lt;/code&gt;, and pick &lt;strong&gt;Edit Fields (Set)&lt;/strong&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Click &lt;strong&gt;Add Field&lt;/strong&gt; and name it &lt;code&gt;message&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Drag &lt;strong&gt;Day of week&lt;/strong&gt; from the INPUT panel onto the value. n8n writes the expression for you.&lt;/li&gt;
&lt;li&gt;Type the rest of the message after the expression.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The value ends up like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jinja"&gt;&lt;code&gt;&lt;span class="cp"&gt;{{&lt;/span&gt; &lt;span class="nv"&gt;$json&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'Day of week'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="cp"&gt;}}&lt;/span&gt; reminder: please submit last week's timesheets by noon today.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note the bracket notation. The field name has a space in it, so &lt;code&gt;$json.Day of week&lt;/code&gt; would not work; &lt;code&gt;$json['Day of week']&lt;/code&gt; does.&lt;/p&gt;

&lt;p&gt;Click &lt;strong&gt;Execute step&lt;/strong&gt;. The test output reads:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Saturday reminder: please submit last week's timesheets by noon today.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On a real Monday run it starts with Monday.&lt;/p&gt;

&lt;h2&gt;
  
  
  Mistake 1: the workflow was never published
&lt;/h2&gt;

&lt;p&gt;This is the most common reason a Schedule Trigger "doesn't work". Saving the workflow keeps your edits. Execute step runs it once, by hand. Neither one turns the schedule on.&lt;/p&gt;

&lt;p&gt;The workflow only runs by itself after you click &lt;strong&gt;Publish&lt;/strong&gt;. Until then, nothing happens on Monday, no matter how carefully the trigger is configured.&lt;/p&gt;

&lt;p&gt;And if you change the workflow later, publish again: the live version stays the old one until you do.&lt;/p&gt;

&lt;h2&gt;
  
  
  Mistake 2: 8am in the wrong place
&lt;/h2&gt;

&lt;p&gt;"8am" means 8am in the workflow's time zone, which may not be where your team is.&lt;/p&gt;

&lt;p&gt;Click the &lt;strong&gt;···&lt;/strong&gt; next to the workflow name and open &lt;strong&gt;Settings&lt;/strong&gt;. In the lesson, &lt;strong&gt;Timezone&lt;/strong&gt; says &lt;code&gt;Default - America/New York&lt;/code&gt;, so the trigger fires at 8am New York time. If your office is somewhere else, change it here. You can confirm it on any test run: the Timezone field in the trigger output shows the zone it used.&lt;/p&gt;

&lt;h2&gt;
  
  
  Checklist
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;[ ] Trigger Interval set to Weeks, Weeks Between Triggers 1&lt;/li&gt;
&lt;li&gt;[ ] Sunday removed, Monday chosen in Trigger on Weekdays&lt;/li&gt;
&lt;li&gt;[ ] Trigger at Hour 8am, Trigger at Minute 0&lt;/li&gt;
&lt;li&gt;[ ] Execute step run once; you saw one item with Day of week and Timezone&lt;/li&gt;
&lt;li&gt;[ ] &lt;code&gt;message&lt;/code&gt; built with &lt;code&gt;{{ $json['Day of week'] }}&lt;/code&gt; (bracket notation for the space)&lt;/li&gt;
&lt;li&gt;[ ] Workflow Settings &amp;gt; Timezone matches your office&lt;/li&gt;
&lt;li&gt;[ ] &lt;strong&gt;Publish&lt;/strong&gt; clicked, and clicked again after any later change&lt;/li&gt;
&lt;li&gt;[ ] A Gmail or Slack node added to actually send the message&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once it runs unattended, add error handling, because a schedule that fails on a Monday morning fails silently unless something tells you.&lt;/p&gt;

&lt;h2&gt;
  
  
  Practice it
&lt;/h2&gt;

&lt;p&gt;If you want to click through this exact build in a practice copy of the n8n editor (23 steps, about 6 minutes, nothing touches your account), the free lesson is here: &lt;a href="https://learn.ynteractive.com/content/n8n-schedule-trigger-tutorial" rel="noopener noreferrer"&gt;n8n: Run a Workflow on a Schedule (Every Monday at 8am)&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>n8n</category>
      <category>automation</category>
      <category>tutorial</category>
      <category>nocode</category>
    </item>
    <item>
      <title>JavaScript fetch(): Pull Contacts From an API Into an HTML Table in Ten Lines (async, await and nested JSON)</title>
      <dc:creator>Robert Breen</dc:creator>
      <pubDate>Tue, 24 Nov 2026 00:00:00 +0000</pubDate>
      <link>https://dev.to/robert_breen_d96e41ecd765/javascript-fetch-pull-contacts-from-an-api-into-an-html-table-in-ten-lines-async-await-and-18mf</link>
      <guid>https://dev.to/robert_breen_d96e41ecd765/javascript-fetch-pull-contacts-from-an-api-into-an-html-table-in-ten-lines-async-await-and-18mf</guid>
      <description>&lt;p&gt;Most business tools, from CRMs to accounting apps, share their data through an API: a web address that answers with data instead of a page. If someone on your team copies contacts from a CRM into a spreadsheet every week, that's a job for a few lines of JavaScript.&lt;/p&gt;

&lt;p&gt;This walkthrough uses &lt;a href="https://jsonplaceholder.typicode.com/" rel="noopener noreferrer"&gt;JSONPlaceholder&lt;/a&gt;, a free practice API with ten made-up users, and &lt;a href="https://jsfiddle.net/" rel="noopener noreferrer"&gt;JSFiddle&lt;/a&gt; (no account needed). By the end you'll have a "Client contacts" table filled by your own code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: look at the data first
&lt;/h2&gt;

&lt;p&gt;Open this address in your browser:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://jsonplaceholder.typicode.com/users
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You get ten users as JSON. Each one looks roughly like this (trimmed):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Leanne Graham"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"email"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Sincere@april.biz"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"company"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Romaguera-Crona"&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The three fields we want are &lt;code&gt;name&lt;/code&gt;, &lt;code&gt;email&lt;/code&gt; and the company's &lt;code&gt;name&lt;/code&gt;. Note that the company name is &lt;strong&gt;inside&lt;/strong&gt; &lt;code&gt;company&lt;/code&gt;. That nesting matters later.&lt;/p&gt;

&lt;p&gt;Always look at the raw response before writing code. Most "undefined" bugs come from guessing a field name.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: a heading and an empty table
&lt;/h2&gt;

&lt;p&gt;In JSFiddle's &lt;strong&gt;HTML&lt;/strong&gt; panel:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;h3&amp;gt;&lt;/span&gt;Client contacts&lt;span class="nt"&gt;&amp;lt;/h3&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;table&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"contacts"&lt;/span&gt; &lt;span class="na"&gt;border&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"1"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/table&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;JSFiddle often adds closing tags as you type. If you end up with a doubled &lt;code&gt;&amp;lt;/table&amp;gt;&lt;/code&gt; or a stray &lt;code&gt;&amp;gt;&lt;/code&gt;, delete it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: the address and the table
&lt;/h2&gt;

&lt;p&gt;In the &lt;strong&gt;JavaScript&lt;/strong&gt; panel:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'https://jsonplaceholder.typicode.com/users'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;table&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'#contacts'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;querySelector('#contacts')&lt;/code&gt; finds the table by its id, so the code can write into it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: fetch the data
&lt;/h2&gt;

&lt;p&gt;Leave a blank line, then:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;load&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nb"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Three things happen here:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;fetch(url)&lt;/code&gt; asks the address for the data&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;await&lt;/code&gt; waits for the answer, because asking another server takes a moment&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;.json()&lt;/code&gt; turns the response body into a JavaScript array you can loop over (it's also asynchronous, hence the second &lt;code&gt;await&lt;/code&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;await&lt;/code&gt; only works inside a function marked &lt;code&gt;async&lt;/code&gt;, which is why everything lives inside &lt;code&gt;load&lt;/code&gt;. Without &lt;code&gt;await&lt;/code&gt;, the next line would try to use &lt;code&gt;users&lt;/code&gt; before it arrived.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 5: header row and a loop
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="n"&gt;table&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;innerHTML&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;Name&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Company&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Email&amp;lt;/th&amp;gt;&amp;lt;/tr&amp;gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;u&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The first line replaces whatever is in the table with a header row. The loop runs once per user.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 6: one row per contact
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="n"&gt;table&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;innerHTML&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="s1"&gt;'&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;u&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s1"&gt;'&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;u&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;company&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s1"&gt;'&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;u&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;email&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s1"&gt;'&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;u.company.name&lt;/code&gt; reaches inside &lt;code&gt;company&lt;/code&gt; for its &lt;code&gt;name&lt;/code&gt;. If you wrote &lt;code&gt;u.company&lt;/code&gt;, the cell would show &lt;code&gt;[object Object]&lt;/code&gt;. If you wrote &lt;code&gt;u.companyName&lt;/code&gt;, it would show &lt;code&gt;undefined&lt;/code&gt;. Both are the classic symptoms of not looking at the JSON first.&lt;/p&gt;

&lt;p&gt;The two closing braces end the loop and the function.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 7: call it
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nf"&gt;load&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Without this line the function exists but never runs.&lt;/p&gt;

&lt;h2&gt;
  
  
  The whole script
&lt;/h2&gt;

&lt;p&gt;After clicking JSFiddle's &lt;strong&gt;tidy&lt;/strong&gt; icon on the JavaScript panel, it reads:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'https://jsonplaceholder.typicode.com/users'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;table&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'#contacts'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;load&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nb"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="n"&gt;table&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;innerHTML&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;Name&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Company&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Email&amp;lt;/th&amp;gt;&amp;lt;/tr&amp;gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;u&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;table&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;innerHTML&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="s1"&gt;'&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;u&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s1"&gt;'&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;
      &lt;span class="n"&gt;u&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;company&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s1"&gt;'&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;u&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;email&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s1"&gt;'&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;load&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Click &lt;strong&gt;Run&lt;/strong&gt;. The Result panel shows a Client contacts table with ten names, company names and emails, all read from the API.&lt;/p&gt;

&lt;h2&gt;
  
  
  Making it sturdier
&lt;/h2&gt;

&lt;p&gt;The beginner version is deliberately short. Before you point it at anything real, three upgrades are worth knowing:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Check the response.&lt;/strong&gt; &lt;code&gt;fetch&lt;/code&gt; only rejects on network failure. A 404 or 500 still "succeeds", so check &lt;code&gt;response.ok&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nb"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;table&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;innerHTML&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Could not load contacts ('&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s1"&gt;')&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Use textContent for data you don't control.&lt;/strong&gt; Building HTML by string concatenation is fine for a practice API, but with real data a name like &lt;code&gt;&amp;lt;img onerror=...&amp;gt;&lt;/code&gt; would be treated as HTML. Creating cells with &lt;code&gt;document.createElement('td')&lt;/code&gt; and setting &lt;code&gt;.textContent&lt;/code&gt; avoids that.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Build once, write once.&lt;/strong&gt; &lt;code&gt;innerHTML +=&lt;/code&gt; re-parses the whole table on every loop. For ten rows nobody notices; for a few thousand, build the rows into one string (or a DocumentFragment) and write it once.&lt;/p&gt;

&lt;h2&gt;
  
  
  From practice API to a real CRM
&lt;/h2&gt;

&lt;p&gt;A real CRM API works the same way, with one addition: a key that proves who you are, usually sent in a header:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nb"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;Authorization&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'Bearer '&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Never put a real key in public code like a shared fiddle or a public web page. Anyone can read it in the browser. For anything real, the key belongs on a server or in an automation tool that stores credentials for you.&lt;/p&gt;

&lt;h2&gt;
  
  
  Checklist
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;[ ] Opened the API address and read the raw JSON first&lt;/li&gt;
&lt;li&gt;[ ] Table has an &lt;code&gt;id&lt;/code&gt; the script can find&lt;/li&gt;
&lt;li&gt;[ ] &lt;code&gt;await&lt;/code&gt; used inside an &lt;code&gt;async&lt;/code&gt; function, for both &lt;code&gt;fetch&lt;/code&gt; and &lt;code&gt;.json()&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;[ ] Nested fields read with dot notation (&lt;code&gt;u.company.name&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;[ ] &lt;code&gt;load()&lt;/code&gt; actually called&lt;/li&gt;
&lt;li&gt;[ ] &lt;code&gt;response.ok&lt;/code&gt; checked before using the data&lt;/li&gt;
&lt;li&gt;[ ] No real API key in browser code&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Practice it
&lt;/h2&gt;

&lt;p&gt;This is based on a free step-by-step lesson where you type every line yourself in a practice copy of JSFiddle that checks your work (9 steps, about 12 minutes): &lt;a href="https://learn.ynteractive.com/content/js-api-contacts-table" rel="noopener noreferrer"&gt;JavaScript: Pull Contacts from an API into a Table&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>api</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Python pandas: Clean a Messy Invoice Export Before You Total It (strip, title, astype and drop_duplicates)</title>
      <dc:creator>Robert Breen</dc:creator>
      <pubDate>Mon, 23 Nov 2026 22:00:00 +0000</pubDate>
      <link>https://dev.to/robert_breen_d96e41ecd765/python-pandas-clean-a-messy-invoice-export-before-you-total-it-strip-title-astype-and-e60</link>
      <guid>https://dev.to/robert_breen_d96e41ecd765/python-pandas-clean-a-messy-invoice-export-before-you-total-it-strip-title-astype-and-e60</guid>
      <description>&lt;p&gt;Exports from accounting and billing tools are rarely clean. A name has a trailing space. Someone typed a client in capitals. Amounts come out as text with commas. One invoice is in the file twice.&lt;/p&gt;

&lt;p&gt;Total that as it is and you get the wrong answer, quietly. This walkthrough fixes a small made-up export (Lakeside Office Supply) with three pandas lines in &lt;a href="https://colab.research.google.com/" rel="noopener noreferrer"&gt;Google Colab&lt;/a&gt;, then totals it. Free Colab is enough.&lt;/p&gt;

&lt;h2&gt;
  
  
  The messy export
&lt;/h2&gt;

&lt;p&gt;Start a new notebook and run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;pandas&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the next cell, type the data exactly as the export has it, mess included:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;clients&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'maple dental '&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Cobalt Legal'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'COBALT LEGAL'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;' Harbor Accounting'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;amounts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'1,250'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'860'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'860'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'640'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;numbers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;101&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;102&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;102&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;103&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Look closely:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;'maple dental '&lt;/code&gt; has a trailing space and no capitals&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;'COBALT LEGAL'&lt;/code&gt; is the same client as &lt;code&gt;'Cobalt Legal'&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;' Harbor Accounting'&lt;/code&gt; has a leading space&lt;/li&gt;
&lt;li&gt;every amount is a string, and &lt;code&gt;'1,250'&lt;/code&gt; has a comma&lt;/li&gt;
&lt;li&gt;invoice 102 appears twice&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Press &lt;strong&gt;Shift+Enter&lt;/strong&gt;, then put it in one table:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;invoices&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;DataFrame&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s1"&gt;'client'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;clients&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'invoice'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;numbers&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'amount'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;amounts&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;invoices&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Four rows. To a computer, "Cobalt Legal" and "COBALT LEGAL" are two different clients, and "1,250" is text, not a number.&lt;/p&gt;

&lt;h2&gt;
  
  
  What goes wrong if you total it now
&lt;/h2&gt;

&lt;p&gt;Two things:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A &lt;code&gt;groupby('client')&lt;/code&gt; would put Cobalt Legal in two groups, so the same invoice is counted under two spellings.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;sum()&lt;/code&gt; on a text column doesn't add numbers. It joins the strings together (&lt;code&gt;'860860'&lt;/code&gt;), or fails, depending on what's in the column.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Neither raises an obvious error in a quick look. That's why the cleanup comes first.&lt;/p&gt;

&lt;h2&gt;
  
  
  Clean it: two lines
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;invoices&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'client'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;invoices&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'client'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;strip&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;title&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;invoices&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'amount'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;invoices&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'amount'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;','&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;astype&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Line one:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;.str.strip()&lt;/code&gt; removes spaces at both ends&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;.str.title()&lt;/code&gt; gives every name the same capitals: &lt;code&gt;'maple dental'&lt;/code&gt; becomes &lt;code&gt;'Maple Dental'&lt;/code&gt;, &lt;code&gt;'COBALT LEGAL'&lt;/code&gt; becomes &lt;code&gt;'Cobalt Legal'&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Line two:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;.str.replace(',', '')&lt;/code&gt; removes the thousands comma&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;.astype(int)&lt;/code&gt; turns the text into whole numbers&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The &lt;code&gt;.str&lt;/code&gt; part matters. It applies the string method to every value in the column, not to the column object itself.&lt;/p&gt;

&lt;h2&gt;
  
  
  Drop the duplicate
&lt;/h2&gt;

&lt;p&gt;Now both Cobalt Legal rows are spelled the same, so they're exact copies:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;invoices&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;invoices&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;drop_duplicates&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;invoices&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run it. Three clean rows:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;client&lt;/th&gt;
&lt;th&gt;invoice&lt;/th&gt;
&lt;th&gt;amount&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Maple Dental&lt;/td&gt;
&lt;td&gt;101&lt;/td&gt;
&lt;td&gt;1250&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cobalt Legal&lt;/td&gt;
&lt;td&gt;102&lt;/td&gt;
&lt;td&gt;860&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Harbor Accounting&lt;/td&gt;
&lt;td&gt;103&lt;/td&gt;
&lt;td&gt;640&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Why the order matters
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;drop_duplicates()&lt;/code&gt; only removes rows that match in &lt;strong&gt;every column&lt;/strong&gt;. Before the cleanup, the two invoice-102 rows were &lt;code&gt;'Cobalt Legal'&lt;/code&gt; and &lt;code&gt;'COBALT LEGAL'&lt;/code&gt;. Different strings, so not duplicates, so the copy would have stayed in.&lt;/p&gt;

&lt;p&gt;The rule is: &lt;strong&gt;clean the columns, then de-duplicate, then total.&lt;/strong&gt; Swap the first two and the bug survives without any error message.&lt;/p&gt;

&lt;p&gt;If you'd rather treat "same invoice number" as a duplicate no matter what the other columns say, you can tell pandas which column to compare:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;invoices&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;invoices&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;drop_duplicates&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;subset&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'invoice'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's a judgment call. An invoice number repeated with a &lt;em&gt;different&lt;/em&gt; amount is probably a correction, not a copy, and deserves a human look before you drop it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Total it
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;invoices&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;groupby&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'client'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'amount'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Result:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;client
Cobalt Legal          860
Harbor Accounting     640
Maple Dental         1250
Name: amount, dtype: int64
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Three clients, three invoices, $2,750 in total. Without the cleanup, Cobalt Legal would have shown up twice and been double-counted.&lt;/p&gt;

&lt;p&gt;Want it biggest first? Chain a sort:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;invoices&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;groupby&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'client'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'amount'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sort_values&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ascending&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Reuse it on every export
&lt;/h2&gt;

&lt;p&gt;Next month's export will have the same problems, just different rows. Keep the three cleaning lines together in one cell and run them every time:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;invoices&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'client'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;invoices&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'client'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;strip&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;title&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;invoices&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'amount'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;invoices&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'amount'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;','&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;astype&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;invoices&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;invoices&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;drop_duplicates&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In real life you'd load the file with &lt;code&gt;pd.read_csv(...)&lt;/code&gt; instead of typing the lists, and the same three lines apply.&lt;/p&gt;

&lt;p&gt;A caveat on &lt;code&gt;.title()&lt;/code&gt;: it capitalises every word, so names like "McDonald" or "ABC Plumbing" come out as "Mcdonald" and "Abc Plumbing". For grouping that's fine (they're consistent); for a customer-facing report you may want &lt;code&gt;.str.upper()&lt;/code&gt; or a lookup table instead.&lt;/p&gt;

&lt;h2&gt;
  
  
  Checklist
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;[ ] &lt;code&gt;import pandas as pd&lt;/code&gt; run first&lt;/li&gt;
&lt;li&gt;[ ] Names cleaned with &lt;code&gt;.str.strip().str.title()&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;[ ] Commas removed before &lt;code&gt;.astype(int)&lt;/code&gt; (or it raises a ValueError)&lt;/li&gt;
&lt;li&gt;[ ] Clean first, then &lt;code&gt;drop_duplicates()&lt;/code&gt;, then &lt;code&gt;groupby&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;[ ] Decide whether a repeated invoice number with a different amount is a copy or a correction&lt;/li&gt;
&lt;li&gt;[ ] One total checked by hand against the source file&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Practice it
&lt;/h2&gt;

&lt;p&gt;This comes from a free step-by-step lesson where you type every line yourself in a practice copy of Google Colab that checks your work (10 steps, about 12 minutes): &lt;a href="https://learn.ynteractive.com/content/python-clean-invoice-export" rel="noopener noreferrer"&gt;Python: Clean a Messy Invoice Export Before You Total It&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>python</category>
      <category>pandas</category>
      <category>datascience</category>
      <category>beginners</category>
    </item>
    <item>
      <title>SQL GROUP BY and HAVING: Find Your Top Customers and $3,000 Key Accounts in Eight Rows of Orders</title>
      <dc:creator>Robert Breen</dc:creator>
      <pubDate>Mon, 23 Nov 2026 19:41:02 +0000</pubDate>
      <link>https://dev.to/robert_breen_d96e41ecd765/sql-group-by-and-having-find-your-top-customers-and-3000-key-accounts-in-eight-rows-of-orders-4jh</link>
      <guid>https://dev.to/robert_breen_d96e41ecd765/sql-group-by-and-having-find-your-top-customers-and-3000-key-accounts-in-eight-rows-of-orders-4jh</guid>
      <description>&lt;p&gt;Before a quarterly review, someone usually gets asked two questions: who are our top three customers, and which accounts were worth $3,000 or more this quarter? The usual answer is a spreadsheet, a sort, and a lot of adding up by hand.&lt;/p&gt;

&lt;p&gt;Both questions are four SQL keywords: &lt;code&gt;GROUP BY&lt;/code&gt;, &lt;code&gt;ORDER BY&lt;/code&gt;, &lt;code&gt;LIMIT&lt;/code&gt; and &lt;code&gt;HAVING&lt;/code&gt;. This walkthrough uses a made-up shop, Lakeside Office Supply, with eight orders. You can type all of it into &lt;a href="https://www.db-fiddle.com/" rel="noopener noreferrer"&gt;DB Fiddle&lt;/a&gt; (free, no account needed, MySQL v9 selected).&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: make the orders table
&lt;/h2&gt;

&lt;p&gt;DB Fiddle has two boxes. The left one, &lt;strong&gt;Schema SQL&lt;/strong&gt;, holds the table. Click inside it and type:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="n"&gt;orders&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
&lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="kt"&gt;INT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;order_date&lt;/span&gt; &lt;span class="kt"&gt;DATE&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="n"&gt;customer&lt;/span&gt; &lt;span class="kt"&gt;VARCHAR&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;40&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;amount&lt;/span&gt; &lt;span class="kt"&gt;INT&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Four columns: an id, the order date, the customer and the amount.&lt;/p&gt;

&lt;p&gt;Leave a blank line and add the eight orders. Text goes in single quotes, numbers don't. Every row ends with a comma except the last one, which ends with a semicolon so the database knows the statement is finished:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;INSERT&lt;/span&gt; &lt;span class="k"&gt;INTO&lt;/span&gt; &lt;span class="n"&gt;orders&lt;/span&gt; &lt;span class="k"&gt;VALUES&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'2026-07-02'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Maple Dental'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1250&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'2026-07-15'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Cobalt Legal'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;860&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'2026-07-28'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Northside Realty'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2140&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'2026-08-06'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Cobalt Legal'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2310&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'2026-08-19'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Harbor Accounting'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;640&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'2026-08-27'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Maple Dental'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;980&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'2026-09-09'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Northside Realty'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1890&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'2026-09-22'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Cobalt Legal'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1270&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Four customers, eight orders, one quarter (July to September).&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: total each customer with GROUP BY
&lt;/h2&gt;

&lt;p&gt;In the right box, &lt;strong&gt;Query SQL&lt;/strong&gt;, type:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;customer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;SUM&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;revenue&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;orders&lt;/span&gt;
&lt;span class="k"&gt;GROUP&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;customer&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Click &lt;strong&gt;Run&lt;/strong&gt;. &lt;code&gt;GROUP BY customer&lt;/code&gt; collapses the eight rows into one row per customer, and &lt;code&gt;SUM(amount)&lt;/code&gt; adds up that customer's orders. &lt;code&gt;AS revenue&lt;/code&gt; names the new column.&lt;/p&gt;

&lt;p&gt;You get four rows, but in no useful order.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: biggest first with ORDER BY
&lt;/h2&gt;

&lt;p&gt;Delete the semicolon at the end of the last line, press Enter, and add:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;ORDER&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;revenue&lt;/span&gt; &lt;span class="k"&gt;DESC&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;DESC&lt;/code&gt; means descending, biggest first. Run it:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;customer&lt;/th&gt;
&lt;th&gt;revenue&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Cobalt Legal&lt;/td&gt;
&lt;td&gt;4440&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Northside Realty&lt;/td&gt;
&lt;td&gt;4030&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Maple Dental&lt;/td&gt;
&lt;td&gt;2230&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Harbor Accounting&lt;/td&gt;
&lt;td&gt;640&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Notice you can sort by &lt;code&gt;revenue&lt;/code&gt;, the alias you just created. That works because &lt;code&gt;ORDER BY&lt;/code&gt; runs after the totals are calculated.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: keep the top three with LIMIT
&lt;/h2&gt;

&lt;p&gt;Remove the semicolon again and add one line:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;LIMIT&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The full query now reads:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;customer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;SUM&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;revenue&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;orders&lt;/span&gt;
&lt;span class="k"&gt;GROUP&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;customer&lt;/span&gt;
&lt;span class="k"&gt;ORDER&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;revenue&lt;/span&gt; &lt;span class="k"&gt;DESC&lt;/span&gt;
&lt;span class="k"&gt;LIMIT&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run it: Cobalt Legal, Northside Realty, Maple Dental. That's question one answered.&lt;/p&gt;

&lt;p&gt;One thing to watch: &lt;code&gt;LIMIT&lt;/code&gt; without &lt;code&gt;ORDER BY&lt;/code&gt; gives you three rows, but not necessarily the &lt;em&gt;top&lt;/em&gt; three. Always sort first.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 5: key accounts with HAVING
&lt;/h2&gt;

&lt;p&gt;Question two is different. It's not "the top N" but "everyone over a threshold". Replace the whole query (Ctrl+A, then type) with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;customer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;COUNT&lt;/span&gt;&lt;span class="cm"&gt;(*) AS orders,
SUM(amount) AS revenue
FROM orders
GROUP BY customer
HAVING SUM(amount) &amp;gt;= 3000
ORDER BY revenue DESC;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;COUNT(*)&lt;/code&gt; adds the number of orders next to the revenue. Run it:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;customer&lt;/th&gt;
&lt;th&gt;orders&lt;/th&gt;
&lt;th&gt;revenue&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Cobalt Legal&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;4440&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Northside Realty&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;4030&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Those are the two accounts that get a thank-you call. Change &lt;code&gt;3000&lt;/code&gt; to any other number and the list updates.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why HAVING and not WHERE
&lt;/h2&gt;

&lt;p&gt;This is the part that trips up most beginners. It's tempting to write:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="c1"&gt;-- This does NOT do what you want&lt;/span&gt;
&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;customer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;SUM&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;revenue&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;orders&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;amount&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;3000&lt;/span&gt;
&lt;span class="k"&gt;GROUP&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;customer&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;WHERE&lt;/code&gt; filters &lt;strong&gt;single rows before they are added up&lt;/strong&gt;. No single order in this table is $3,000 or more (the biggest is 2,310), so this returns nothing, even though two customers are clearly over $3,000 in total.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;HAVING&lt;/code&gt; filters &lt;strong&gt;the totals after GROUP BY&lt;/strong&gt;. "Customers worth $3,000 or more" is a question about totals, so it needs &lt;code&gt;HAVING&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;You can use both in the same query. &lt;code&gt;WHERE&lt;/code&gt; first narrows which orders count (say, one month), then &lt;code&gt;HAVING&lt;/code&gt; filters the totals:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;customer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;SUM&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;revenue&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;orders&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;order_date&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="s1"&gt;'2026-08-01'&lt;/span&gt;
&lt;span class="k"&gt;GROUP&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;customer&lt;/span&gt;
&lt;span class="k"&gt;HAVING&lt;/span&gt; &lt;span class="nb"&gt;SUM&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;2000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The order of the clauses
&lt;/h2&gt;

&lt;p&gt;SQL is strict about the order you write things in:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT  ...
FROM    ...
WHERE   ...   -- filters rows
GROUP BY ...  -- makes one row per group
HAVING  ...   -- filters groups
ORDER BY ...  -- sorts the result
LIMIT   ...   -- keeps the first N
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you get a syntax error on a query that looks right, check this order first.&lt;/p&gt;

&lt;h2&gt;
  
  
  Same table, new question
&lt;/h2&gt;

&lt;p&gt;The table didn't change between question one and question two. Only the query did. That's the real shift from spreadsheets: at work the orders table already exists, and every new question from your manager is just a new query. &lt;code&gt;GROUP BY&lt;/code&gt; works on any column: customer, month, region or salesperson.&lt;/p&gt;

&lt;h2&gt;
  
  
  Checklist
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;[ ] Every row in &lt;code&gt;INSERT&lt;/code&gt; ends with a comma, the last with a semicolon&lt;/li&gt;
&lt;li&gt;[ ] &lt;code&gt;GROUP BY&lt;/code&gt; names the column you want one row per&lt;/li&gt;
&lt;li&gt;[ ] &lt;code&gt;ORDER BY ... DESC&lt;/code&gt; before &lt;code&gt;LIMIT&lt;/code&gt;, or the "top three" is random&lt;/li&gt;
&lt;li&gt;[ ] Thresholds on totals go in &lt;code&gt;HAVING&lt;/code&gt;, thresholds on single rows go in &lt;code&gt;WHERE&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;[ ] Clause order: SELECT, FROM, WHERE, GROUP BY, HAVING, ORDER BY, LIMIT&lt;/li&gt;
&lt;li&gt;[ ] One total checked by hand (Cobalt Legal: 860 + 2310 + 1270 = 4440)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Practice it
&lt;/h2&gt;

&lt;p&gt;This is based on a free step-by-step lesson where you type every line yourself in a practice copy of DB Fiddle that checks your work as you go (14 steps, about 12 minutes): &lt;a href="https://learn.ynteractive.com/content/sql-top-customers" rel="noopener noreferrer"&gt;SQL: Top Customers and Key Accounts with GROUP BY and HAVING&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>sql</category>
      <category>beginners</category>
      <category>database</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>n8n Code Node: Replace the Friday Pivot Table With Eight Lines of JavaScript (and the Same Job in Python)</title>
      <dc:creator>Robert Breen</dc:creator>
      <pubDate>Thu, 19 Nov 2026 22:00:00 +0000</pubDate>
      <link>https://dev.to/robert_breen_d96e41ecd765/n8n-code-node-replace-the-friday-pivot-table-with-eight-lines-of-javascript-and-the-same-job-in-4nka</link>
      <guid>https://dev.to/robert_breen_d96e41ecd765/n8n-code-node-replace-the-friday-pivot-table-with-eight-lines-of-javascript-and-the-same-job-in-4nka</guid>
      <description>&lt;p&gt;n8n has a ready-made node for most office jobs. Then there's the leftover: a total nobody planned for, a format that's slightly off, a rule with too many exceptions. That's what the &lt;strong&gt;Code&lt;/strong&gt; node is for.&lt;/p&gt;

&lt;p&gt;The example here is a made-up staffing agency. Every Friday someone builds a pivot table to total each client's hours before invoicing. One Code node does it: total the hours per client and work out the invoice amount at $42 an hour. Then the same job in Python, so you can see what changes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Manual trigger  →  Sample timesheet  →  Code (JavaScript)
                                     ↘  Code (Python)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;No credentials needed.&lt;/p&gt;

&lt;h2&gt;
  
  
  The input
&lt;/h2&gt;

&lt;p&gt;Seven timesheet rows, three clients, each on more than one row:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;worker&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'Ana Ruiz'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'Kessler Logistics'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;hours&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;7.5&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;worker&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'Ben Carter'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'Northgate Dental'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;hours&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;worker&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'Ana Ruiz'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'Kessler Logistics'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;hours&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;worker&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'Chloe Park'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'Alder &amp;amp; Finch Law'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;hours&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;worker&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'Ben Carter'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'Northgate Dental'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;hours&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;4.5&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;worker&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'Dev Malhotra'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'Kessler Logistics'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;hours&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;worker&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'Chloe Park'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'Alder &amp;amp; Finch Law'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;hours&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's itself a Code node (the "Sample timesheet" step). Look at the last line: every object is wrapped as &lt;code&gt;{ json: ... }&lt;/code&gt;. That's the rule.&lt;/p&gt;

&lt;h2&gt;
  
  
  The one rule: items in, items out
&lt;/h2&gt;

&lt;p&gt;Every n8n node receives a list of items and passes a list of items on. The Code node is no different, except you write the middle.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Read the input with &lt;code&gt;$input.all()&lt;/code&gt;. Each item's data is under &lt;code&gt;item.json&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Return a &lt;strong&gt;list&lt;/strong&gt; of items, each with its data under a key called &lt;strong&gt;&lt;code&gt;json&lt;/code&gt;&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Nearly every Code node error is a broken version of that rule: returning a bare value, returning one object instead of a list, or forgetting the &lt;code&gt;json&lt;/code&gt; key. If you see an error saying the node must return an array of objects, that's what happened.&lt;/p&gt;

&lt;h2&gt;
  
  
  Mode: all items or each item
&lt;/h2&gt;

&lt;p&gt;Above the code editor there are two settings. &lt;strong&gt;Mode&lt;/strong&gt; has two choices:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Mode&lt;/th&gt;
&lt;th&gt;Runs&lt;/th&gt;
&lt;th&gt;Good for&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Run Once for All Items&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;One time, sees the whole list&lt;/td&gt;
&lt;td&gt;Totals, rankings, summaries, de-duplication&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Run Once for Each Item&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Once per item&lt;/td&gt;
&lt;td&gt;A small change to every row, like splitting a full name&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Adding things up across rows needs the first. In "each item" mode your code only ever sees one row, so it can't total anything.&lt;/p&gt;

&lt;h2&gt;
  
  
  The JavaScript
&lt;/h2&gt;

&lt;p&gt;Add a &lt;strong&gt;Code&lt;/strong&gt; node after the sample, keep &lt;strong&gt;Mode: Run Once for All Items&lt;/strong&gt; and &lt;strong&gt;Language: JavaScript&lt;/strong&gt;, select the starter code and paste over it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;totals&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="nv"&gt;$input&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;all&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="n"&gt;totals&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;totals&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;hours&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;entries&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;totals&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;hours&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;hours&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;invoice&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;hours&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;42&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Read it once:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Loop over every incoming item.&lt;/li&gt;
&lt;li&gt;Add its hours to that client's running total.&lt;/li&gt;
&lt;li&gt;Turn the totals object into a list, one item per client, each wrapped in &lt;code&gt;{ json: ... }&lt;/code&gt;, with &lt;code&gt;hours * 42&lt;/code&gt; as the invoice.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Execute step&lt;/strong&gt;. Seven items in, three out:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;client&lt;/th&gt;
&lt;th&gt;hours&lt;/th&gt;
&lt;th&gt;invoice&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Kessler Logistics&lt;/td&gt;
&lt;td&gt;23.5&lt;/td&gt;
&lt;td&gt;987&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Northgate Dental&lt;/td&gt;
&lt;td&gt;12.5&lt;/td&gt;
&lt;td&gt;525&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Alder &amp;amp; Finch Law&lt;/td&gt;
&lt;td&gt;13&lt;/td&gt;
&lt;td&gt;546&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Check one by hand before you trust it: Kessler is 7.5 + 8 + 8 = 23.5, and 23.5 × 42 = 987. Good.&lt;/p&gt;

&lt;h2&gt;
  
  
  The same job in Python
&lt;/h2&gt;

&lt;p&gt;Open &lt;strong&gt;Language&lt;/strong&gt; and choose &lt;strong&gt;Python&lt;/strong&gt;. The starter code changes, and so does the hint under the editor: input comes from &lt;code&gt;_items&lt;/code&gt;, and imports are off unless your instance allows them.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;totals&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;_items&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;row&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"json"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="n"&gt;totals&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"client"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;totals&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"client"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"hours"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"json"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"client"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"hours"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;hours&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"invoice"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;hours&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;42&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;hours&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;totals&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;items&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Same three items out.&lt;/p&gt;

&lt;p&gt;What's different in Python:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;JavaScript&lt;/th&gt;
&lt;th&gt;Python&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;All items&lt;/td&gt;
&lt;td&gt;&lt;code&gt;$input.all()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;_items&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;One item (each-item mode)&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;$input.item&lt;/code&gt; / &lt;code&gt;$json&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;&lt;code&gt;_item&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;$&lt;/code&gt; helpers&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Imports&lt;/td&gt;
&lt;td&gt;—&lt;/td&gt;
&lt;td&gt;Disabled unless the instance allows them&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Internet access&lt;/td&gt;
&lt;td&gt;—&lt;/td&gt;
&lt;td&gt;None (sandboxed)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Return shape&lt;/td&gt;
&lt;td&gt;List of &lt;code&gt;{ json: {...} }&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;List of &lt;code&gt;{"json": {...}}&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Plain Python with loops, dictionaries and list comprehensions covers most reshaping jobs. If you need a library or data from the web, fetch it with the &lt;strong&gt;HTTP Request&lt;/strong&gt; node and process the result in code, or use JavaScript.&lt;/p&gt;

&lt;p&gt;Which to pick? JavaScript is n8n's home language: it has the &lt;code&gt;$&lt;/code&gt; helpers, date tools and fewer limits. Use Python when you or your team read it more easily and the job needs no libraries.&lt;/p&gt;

&lt;h2&gt;
  
  
  When not to use code
&lt;/h2&gt;

&lt;p&gt;Reach for a ready-made node first. They're easier for the next person to read:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Filter&lt;/strong&gt; and &lt;strong&gt;Edit Fields&lt;/strong&gt; for keep-this, rename-that.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;If&lt;/strong&gt; and &lt;strong&gt;Switch&lt;/strong&gt; for routing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Summarize&lt;/strong&gt; for simple totals.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Use the Code node when the job would need two or three of those chained awkwardly, or a rule none of them can express. And when you do, add error alerts, because code is where surprises hide.&lt;/p&gt;

&lt;h2&gt;
  
  
  You don't have to write it from scratch
&lt;/h2&gt;

&lt;p&gt;You need to be able to &lt;em&gt;read&lt;/em&gt; a short loop, not write one cold. A workable approach: describe the input (paste one item's JSON) and the output you want to an AI assistant, remind it of the &lt;code&gt;{ json: ... }&lt;/code&gt; return shape, paste what it gives you, run it on test data, and check one result by hand like the Kessler check above.&lt;/p&gt;

&lt;h2&gt;
  
  
  Checklist
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;[ ] Mode is &lt;strong&gt;Run Once for All Items&lt;/strong&gt; for totals&lt;/li&gt;
&lt;li&gt;[ ] Input read with &lt;code&gt;$input.all()&lt;/code&gt; (JS) or &lt;code&gt;_items&lt;/code&gt; (Python)&lt;/li&gt;
&lt;li&gt;[ ] Every returned item is wrapped in &lt;code&gt;json&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;[ ] Return value is a list, even for one result&lt;/li&gt;
&lt;li&gt;[ ] One output checked by hand&lt;/li&gt;
&lt;li&gt;[ ] No imports in Python unless your instance allows them&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Practice it
&lt;/h2&gt;

&lt;p&gt;This is a free step-by-step lesson where you build both versions in a practice copy of n8n (15 steps, about 6 minutes, no account), with the workflow JSON to import: &lt;a href="https://learn.ynteractive.com/content/n8n-code-node-javascript-python" rel="noopener noreferrer"&gt;n8n: Run JavaScript or Python in the Code Node&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>n8n</category>
      <category>javascript</category>
      <category>python</category>
      <category>automation</category>
    </item>
    <item>
      <title>n8n Filter Node: Six Leases In, Three Out. Open the Discarded Pile Before You Trust It (Then Clean Up With Edit Fields)</title>
      <dc:creator>Robert Breen</dc:creator>
      <pubDate>Thu, 19 Nov 2026 19:00:00 +0000</pubDate>
      <link>https://dev.to/robert_breen_d96e41ecd765/n8n-filter-node-six-leases-in-three-out-open-the-discarded-pile-before-you-trust-it-then-clean-2kf4</link>
      <guid>https://dev.to/robert_breen_d96e41ecd765/n8n-filter-node-six-leases-in-three-out-open-the-discarded-pile-before-you-trust-it-then-clean-2kf4</guid>
      <description>&lt;p&gt;Most office lists are mostly noise. Forty rows, and six need something done today.&lt;/p&gt;

&lt;p&gt;In n8n the step that finds those six is the &lt;strong&gt;Filter&lt;/strong&gt; node, and the step that turns each one into something readable is &lt;strong&gt;Edit Fields (Set)&lt;/strong&gt;. Together they shorten a list with no code. This walkthrough uses a made-up property management office that needs to send renewal offers before leases run out.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Manual trigger  →  Sample leases  →  Filter  →  Edit Fields (Set)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The sample data lives inside the workflow, so you can rebuild it with no accounts connected. In a real office the second node would be Google Sheets or Airtable, and an email or Slack step would follow. The middle two nodes stay the same.&lt;/p&gt;

&lt;h2&gt;
  
  
  The data
&lt;/h2&gt;

&lt;p&gt;Six items, one per lease:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;tenant&lt;/th&gt;
&lt;th&gt;unit&lt;/th&gt;
&lt;th&gt;status&lt;/th&gt;
&lt;th&gt;days_left&lt;/th&gt;
&lt;th&gt;rent&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Dana Whitfield&lt;/td&gt;
&lt;td&gt;2B&lt;/td&gt;
&lt;td&gt;Active&lt;/td&gt;
&lt;td&gt;21&lt;/td&gt;
&lt;td&gt;1850&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Marcus Oyelaran&lt;/td&gt;
&lt;td&gt;4A&lt;/td&gt;
&lt;td&gt;Active&lt;/td&gt;
&lt;td&gt;143&lt;/td&gt;
&lt;td&gt;2100&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Priya Raman&lt;/td&gt;
&lt;td&gt;1C&lt;/td&gt;
&lt;td&gt;Active&lt;/td&gt;
&lt;td&gt;48&lt;/td&gt;
&lt;td&gt;1620&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Tom Becker&lt;/td&gt;
&lt;td&gt;3D&lt;/td&gt;
&lt;td&gt;Notice given&lt;/td&gt;
&lt;td&gt;30&lt;/td&gt;
&lt;td&gt;1975&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Elena Soto&lt;/td&gt;
&lt;td&gt;5A&lt;/td&gt;
&lt;td&gt;Active&lt;/td&gt;
&lt;td&gt;59&lt;/td&gt;
&lt;td&gt;2240&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Grace Lindqvist&lt;/td&gt;
&lt;td&gt;2D&lt;/td&gt;
&lt;td&gt;Active&lt;/td&gt;
&lt;td&gt;212&lt;/td&gt;
&lt;td&gt;1790&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The rule: send a renewal offer to every &lt;strong&gt;Active&lt;/strong&gt; lease that ends in &lt;strong&gt;60 days or less&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;If you want to paste the sample in yourself, a Code node returning this does the job:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;tenant&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'Dana Whitfield'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;unit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'2B'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'Active'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;days_left&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;21&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;rent&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1850&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;tenant&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'Marcus Oyelaran'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;unit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'4A'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'Active'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;days_left&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;143&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;rent&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2100&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;tenant&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'Priya Raman'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;unit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'1C'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'Active'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;days_left&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;48&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;rent&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1620&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;tenant&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'Tom Becker'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;unit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'3D'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'Notice given'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;days_left&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;rent&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1975&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;tenant&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'Elena Soto'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;unit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'5A'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'Active'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;days_left&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;59&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;rent&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2240&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;tenant&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'Grace Lindqvist'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;unit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'2D'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'Active'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;days_left&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;212&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;rent&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1790&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 1: Two conditions joined by AND
&lt;/h2&gt;

&lt;p&gt;Add a &lt;strong&gt;Filter&lt;/strong&gt; node ("Keep only items matching a condition").&lt;/p&gt;

&lt;p&gt;Each condition has three parts: a value from the item, a comparison, and what to compare it with.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Drag &lt;code&gt;days_left&lt;/code&gt; from the INPUT panel onto the first box. n8n writes &lt;code&gt;{{ $json.days_left }}&lt;/code&gt; for you.&lt;/li&gt;
&lt;li&gt;Because the field is a number, n8n offers number comparisons. It defaults to &lt;strong&gt;is equal to&lt;/strong&gt;. Change it to &lt;strong&gt;is less than or equal to&lt;/strong&gt; and type &lt;code&gt;60&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Add condition&lt;/strong&gt;. Drag &lt;code&gt;status&lt;/code&gt; onto the new first box. Leave &lt;strong&gt;is equal to&lt;/strong&gt; and type &lt;code&gt;Active&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The two rows are joined by &lt;strong&gt;AND&lt;/strong&gt;, so an item has to pass both. Switch to &lt;strong&gt;OR&lt;/strong&gt; when passing either one is enough.&lt;/p&gt;

&lt;p&gt;In the workflow JSON, those conditions look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="nl"&gt;"conditions"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"leftValue"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"={{ $json.days_left }}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"rightValue"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"operator"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"number"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"operation"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"lte"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"leftValue"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"={{ $json.status }}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"rightValue"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Active"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"operator"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"string"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"operation"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"equals"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="nl"&gt;"combinator"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"and"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note the &lt;code&gt;type&lt;/code&gt; on each operator. That detail comes back below when a filter returns nothing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Open the Discarded pile
&lt;/h2&gt;

&lt;p&gt;Click &lt;strong&gt;Execute step&lt;/strong&gt;. The output has two piles: &lt;strong&gt;Kept&lt;/strong&gt; and &lt;strong&gt;Discarded&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Kept has three items: Dana, Priya and Elena.&lt;/p&gt;

&lt;p&gt;Don't stop there. Open &lt;strong&gt;Discarded&lt;/strong&gt; and check each reason:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Marcus&lt;/strong&gt;: 143 days left. Correct.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Grace&lt;/strong&gt;: 212 days left. Correct.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tom&lt;/strong&gt;: only 30 days left, yet dropped. Also correct, because his status is &lt;strong&gt;Notice given&lt;/strong&gt;. He's leaving, so he doesn't get an offer.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Tom is the reason this check matters. If you had built the filter on &lt;code&gt;days_left&lt;/code&gt; alone, he'd get a renewal offer for a unit he's already moving out of. If you'd typed &lt;code&gt;active&lt;/code&gt; in lowercase with case sensitivity on, &lt;em&gt;everyone&lt;/em&gt; would be in Discarded. Either way, the Discarded pile shows you in one click. &lt;strong&gt;A filter that silently drops the wrong rows is worse than no filter.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Edit Fields (Set) keeps only what you name
&lt;/h2&gt;

&lt;p&gt;Add &lt;strong&gt;Edit Fields (Set)&lt;/strong&gt; after the Filter.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Drag &lt;code&gt;tenant&lt;/code&gt; onto &lt;strong&gt;Drag input fields here&lt;/strong&gt;. n8n names the field and fills in the value.&lt;/li&gt;
&lt;li&gt;Do the same with &lt;code&gt;unit&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Add Field&lt;/strong&gt;, name it &lt;code&gt;reminder&lt;/code&gt;, and set the value to:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Lease for unit {{ $json.unit }} ends in {{ $json.days_left }} days. Send {{ $json.tenant }} the renewal offer.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Click &lt;strong&gt;Execute step&lt;/strong&gt;. Three items come out with three fields each:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"tenant"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Dana Whitfield"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"unit"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"2B"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"reminder"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Lease for unit 2B ends in 21 days. Send Dana Whitfield the renewal offer."&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;status&lt;/code&gt; and &lt;code&gt;rent&lt;/code&gt; are gone. Edit Fields builds a &lt;strong&gt;new&lt;/strong&gt; item from the fields you set and leaves everything else out. That's what you want before an email or Slack step: nothing extra leaks into the message.&lt;/p&gt;

&lt;p&gt;When you want to add one field and keep the rest, turn on &lt;strong&gt;Include Other Input Fields&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;(Edit Fields used to be called &lt;strong&gt;Set&lt;/strong&gt;. Older tutorials and template JSON still use that name, and the node type is still &lt;code&gt;n8n-nodes-base.set&lt;/code&gt;.)&lt;/p&gt;

&lt;h2&gt;
  
  
  Why does my Filter return no items?
&lt;/h2&gt;

&lt;p&gt;Almost always one of these:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Type mismatch.&lt;/strong&gt; The field is text (&lt;code&gt;"60"&lt;/code&gt;) and the comparison is a number one. Data from spreadsheets and CSVs often arrives as strings. Turn on &lt;strong&gt;Convert types where required&lt;/strong&gt; in the Filter's options.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Case.&lt;/strong&gt; &lt;code&gt;Active&lt;/code&gt; vs &lt;code&gt;active&lt;/code&gt;. Check the spelling against the INPUT panel, or turn off case sensitivity.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Wrong field name.&lt;/strong&gt; Dragging from INPUT avoids typos; typing an expression by hand invites them.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In all three cases, the Discarded pile shows you the values n8n actually compared.&lt;/p&gt;

&lt;h2&gt;
  
  
  Filter or If?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Filter&lt;/strong&gt; drops what fails. Use it when the rest of the workflow only cares about the matches.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;If&lt;/strong&gt; keeps both sides and sends them down two paths (true and false). Use it when the other rows need steps of their own.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Switch&lt;/strong&gt; routes to more than two paths, with a fallback output.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And when a rule gets too awkward for conditions, a few lines in a Code node will do it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Checklist
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;[ ] Conditions built by dragging fields from INPUT&lt;/li&gt;
&lt;li&gt;[ ] Number fields use a number comparison&lt;/li&gt;
&lt;li&gt;[ ] AND vs OR chosen on purpose&lt;/li&gt;
&lt;li&gt;[ ] Discarded pile opened and each reason checked&lt;/li&gt;
&lt;li&gt;[ ] Convert types on for spreadsheet data&lt;/li&gt;
&lt;li&gt;[ ] Edit Fields keeps only the fields the next step needs&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Practice it
&lt;/h2&gt;

&lt;p&gt;This is a free step-by-step lesson where you do each click yourself in a practice copy of n8n (26 steps, about 7 minutes, no account), with the workflow JSON to import: &lt;a href="https://learn.ynteractive.com/content/n8n-filter-node-edit-fields-set" rel="noopener noreferrer"&gt;n8n: Keep Only the Rows That Matter with Filter and Edit Fields&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>n8n</category>
      <category>automation</category>
      <category>nocode</category>
      <category>productivity</category>
    </item>
    <item>
      <title>n8n Respond to Webhook: Your Form Gets "Workflow was started" Instead of a Reply. Change One Setting, Add One Node</title>
      <dc:creator>Robert Breen</dc:creator>
      <pubDate>Thu, 19 Nov 2026 16:00:00 +0000</pubDate>
      <link>https://dev.to/robert_breen_d96e41ecd765/n8n-respond-to-webhook-your-form-gets-workflow-was-started-instead-of-a-reply-change-one-1p8a</link>
      <guid>https://dev.to/robert_breen_d96e41ecd765/n8n-respond-to-webhook-your-form-gets-workflow-was-started-instead-of-a-reply-change-one-1p8a</guid>
      <description>&lt;p&gt;A website form that shows nothing after &lt;strong&gt;Send&lt;/strong&gt; gets sent twice. Or the visitor calls the office to ask if it went through.&lt;/p&gt;

&lt;p&gt;If that form posts to an n8n webhook, the fix is two settings and one node. This walkthrough builds it for a made-up architecture studio: a homeowner sends a consultation request, n8n builds a confirmation with their name in it, and sends it back to the page in the same second.&lt;/p&gt;

&lt;p&gt;The workflow is three nodes and needs no credentials, so you can rebuild it in your own n8n in a few minutes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Webhook  →  Edit Fields (Set)  →  Respond to Webhook
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Why your webhook answers "Workflow was started"
&lt;/h2&gt;

&lt;p&gt;The Webhook node has a &lt;strong&gt;Respond&lt;/strong&gt; setting with four choices:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Respond&lt;/th&gt;
&lt;th&gt;What the caller gets&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;Immediately&lt;/strong&gt; (default)&lt;/td&gt;
&lt;td&gt;An instant "Workflow was started", before any of your steps run&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;When Last Node Finishes&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;The output of the last node that ran&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Using 'Respond to Webhook' Node&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Whatever a Respond to Webhook node sends, when it sends it&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Streaming&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;A streamed response&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The default is &lt;strong&gt;Immediately&lt;/strong&gt;. That's fine for fire-and-forget events, but it means the caller hears back before your workflow has done anything useful. A form can't show a confirmation built from data that doesn't exist yet.&lt;/p&gt;

&lt;p&gt;The other half of the trap: a &lt;strong&gt;Respond to Webhook&lt;/strong&gt; node does nothing by itself. The Webhook node has to be told to wait for it. n8n shows a reminder under the Respond field once you pick the right option, and the Respond to Webhook node carries the matching note at the top of its panel. They only work as a pair.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Catch the request
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Add first step&lt;/strong&gt; → &lt;strong&gt;On webhook call&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;HTTP Method&lt;/strong&gt;: change GET to &lt;strong&gt;POST&lt;/strong&gt;. Website forms send their answers with POST.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Path&lt;/strong&gt;: replace the random string with something readable: &lt;code&gt;consultation-request&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Step 2: Make the webhook wait
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Open &lt;strong&gt;Respond&lt;/strong&gt; (it says &lt;strong&gt;Immediately&lt;/strong&gt;).&lt;/li&gt;
&lt;li&gt;Choose &lt;strong&gt;Using 'Respond to Webhook' Node&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Listen for test event&lt;/strong&gt; and send a test request to the &lt;strong&gt;Test URL&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Any HTTP client works for the test. With curl, using your own Test URL:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -X POST &lt;span class="s2"&gt;"https://YOUR-N8N/webhook-test/consultation-request"&lt;/span&gt; \
  -H &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; \
  -d &lt;span class="s1"&gt;'{"name":"Jordan Ellis","email":"jordan.ellis@example.com","project_type":"kitchen extension","budget":80000}'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One item arrives. The form answers sit under &lt;code&gt;body&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"body"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Jordan Ellis"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"email"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"jordan.ellis@example.com"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"project_type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"kitchen extension"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"budget"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;80000&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note the &lt;code&gt;body&lt;/code&gt; level. It's why the expression in the next step is &lt;code&gt;$json.body.name&lt;/code&gt; and not &lt;code&gt;$json.name&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Build the reply with Edit Fields
&lt;/h2&gt;

&lt;p&gt;Add &lt;strong&gt;Edit Fields (Set)&lt;/strong&gt; after the Webhook and create two fields:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Name&lt;/th&gt;
&lt;th&gt;Value&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;message&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;{{ $json.body.name }}, we got your request. We will call you within one business day.&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;status&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;received&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;You can type the expression, or drag &lt;code&gt;name&lt;/code&gt; from the INPUT panel onto the value box and n8n writes it for you. Then type the rest of the sentence after it.&lt;/p&gt;

&lt;p&gt;Click &lt;strong&gt;Execute step&lt;/strong&gt;. The output has only your two fields:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"message"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Jordan Ellis, we got your request. We will call you within one business day."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"status"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"received"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is the quiet benefit of Edit Fields here: &lt;strong&gt;the email and the budget stay inside n8n&lt;/strong&gt;. Only the fields you set are sent back to the browser. If you reply with the raw webhook item instead, you echo the whole request, headers included.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;status&lt;/code&gt; field is for the website: its code can check for &lt;code&gt;received&lt;/code&gt; and show a green tick.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: Send it back
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Add &lt;strong&gt;Respond to Webhook&lt;/strong&gt; after Edit Fields.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Respond With&lt;/strong&gt;: leave it on &lt;strong&gt;First Incoming Item&lt;/strong&gt;. That's the item Edit Fields just built.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Add option&lt;/strong&gt; → &lt;strong&gt;Response Code&lt;/strong&gt; → &lt;code&gt;200&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Execute step&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The other Respond With choices are worth knowing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;All Incoming Items&lt;/strong&gt; sends a list (useful when you return several rows).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;JSON&lt;/strong&gt; lets you write the reply by hand, with expressions in it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Text&lt;/strong&gt; sends plain text or HTML.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Redirect&lt;/strong&gt; sends the visitor to another page, such as a thank-you page.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No Data&lt;/strong&gt; sends only the response code.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And the response code is how the caller knows what happened: &lt;code&gt;200&lt;/code&gt; for OK, &lt;code&gt;201&lt;/code&gt; when something was created, &lt;code&gt;400&lt;/code&gt; when the request was wrong. A form's script can branch on it.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the front end sees
&lt;/h2&gt;

&lt;p&gt;On the website side, the form's submit handler just reads the JSON. A minimal version:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nb"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"https://YOUR-N8N/webhook/consultation-request"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;method&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"POST"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s2"&gt;"Content-Type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"application/json"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;formData&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ok&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s2"&gt;"received"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;showConfirmation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice that URL has &lt;code&gt;/webhook/&lt;/code&gt;, not &lt;code&gt;/webhook-test/&lt;/code&gt;. That's the last step.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 5: Test URL vs Production URL
&lt;/h2&gt;

&lt;p&gt;Every Webhook node has two addresses:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Path contains&lt;/th&gt;
&lt;th&gt;Works when&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Test URL&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/webhook-test/&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Once, each time you click &lt;strong&gt;Listen for test event&lt;/strong&gt;. Data shows in the editor.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Production URL&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/webhook/&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;All the time, but &lt;strong&gt;only after the workflow is published&lt;/strong&gt;.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Pasting the Test URL into a live website is the most common webhook mistake. It works while you're watching the editor and stops the moment you close it. Use the Production URL in the form, then &lt;strong&gt;Publish&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where to put the Respond node
&lt;/h2&gt;

&lt;p&gt;Put Respond to Webhook at the point where the answer is ready, not necessarily at the end. Steps after it still run.&lt;/p&gt;

&lt;p&gt;That matters when the workflow also does slow things: writing to a sheet, sending an email to the office, calling an AI model. Reply to the visitor first, then do the slow work after the Respond node. The form gets its confirmation in a second instead of waiting on Gmail.&lt;/p&gt;

&lt;p&gt;If only some requests should get a reply, put a Filter or an If node before the response.&lt;/p&gt;

&lt;h2&gt;
  
  
  Quick checklist
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;[ ] Webhook &lt;strong&gt;HTTP Method&lt;/strong&gt; is POST&lt;/li&gt;
&lt;li&gt;[ ] Webhook &lt;strong&gt;Respond&lt;/strong&gt; is &lt;strong&gt;Using 'Respond to Webhook' Node&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;[ ] Expressions read from &lt;code&gt;$json.body.&amp;lt;field&amp;gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;[ ] Edit Fields returns only what the browser should see&lt;/li&gt;
&lt;li&gt;[ ] Respond to Webhook sends &lt;strong&gt;First Incoming Item&lt;/strong&gt; with a &lt;strong&gt;Response Code&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;[ ] The website uses the &lt;strong&gt;Production URL&lt;/strong&gt; (&lt;code&gt;/webhook/&lt;/code&gt;) and the workflow is &lt;strong&gt;published&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;[ ] Slow steps come &lt;strong&gt;after&lt;/strong&gt; the Respond node&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Practice it
&lt;/h2&gt;

&lt;p&gt;I built this as a free step-by-step lesson where you do every click in a practice copy of the n8n editor (31 steps, about 8 minutes, no account needed). It also has the workflow JSON to import: &lt;a href="https://learn.ynteractive.com/content/n8n-respond-to-webhook-node" rel="noopener noreferrer"&gt;n8n: Reply to a Web Form Instantly with Respond to Webhook&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>n8n</category>
      <category>webhooks</category>
      <category>automation</category>
      <category>api</category>
    </item>
  </channel>
</rss>
