Skip to main content

I’m having an issue with zip codes losing their leading zeros in Zapier. In Norway, some zip codes start with a zero (e.g., 0193), and I need to make sure they stay exactly 4 digits long.

I have a Zap that grabs a zip code and processes it in a Code by Zapier step before sending it to Google Sheets. The column in Google Sheets is already set to plain text, so the issue isn’t on that end.

The weird thing is:

The input data in Zapier shows the zip code correctly with the zero (e.g., 0193).

But the output data removes the zero and turns it into 193.

When I check the JavaScript Code Output window in Zapier, the leading zero is already missing before it even reaches Google Sheets. So the issue isn’t in Sheets, it’s happening somewhere in Zapier’s input/output handling.

I’m using this simple JavaScript code to make sure zip codes are always 4 digits:

javascript
Copy
Edit
const zipCode = inputData.zipcode.toString().padStart(4, '0');  
return { paddedZip: zipCode };  
But for some reason, Zapier still strips the leading zero. I only want leading zeros added if the zip code is less than 4 digits—if it’s already 4 digits like 4014, it should stay the same.

Anyone know what’s going on? Is Zapier automatically treating the zip code as a number somewhere? How do I make sure it keeps the zero?

Thanks for any help!

Be the first to reply!