I’m working on a HubSpot form and need help setting up automatic population of city and state fields when someone enters their postal code. Right now users have to manually fill in all three fields which seems redundant.
I’ve seen this functionality on other websites where you just type in your zip code and the city and state appear automatically. I’m wondering what’s the best approach to implement this in HubSpot forms?
I’m not super technical but I can follow step-by-step instructions if someone could walk me through the process. Are there any specific APIs or JavaScript snippets that work well with HubSpot? I want to make sure the solution is reliable and works for most US zip codes.
Any detailed guidance would be really helpful. Thanks for your time!
We implemented this with Google Places API about a year ago, and it works great. You’ll need to acquire an API key from the Google Cloud Console, but their geocoding service accurately processes postal codes and provides reliable city/state data. You can add the API script to your HubSpot form and create a function that triggers when the postal code field is exited. Google’s API excels at managing unique cases like military postal codes and PO boxes which often cause issues with other services. The only downside is the cost; however, the free tier should suffice for most small to medium-sized businesses unless your form submissions are extensive. Their documentation is comprehensive and includes various code examples.
i just use zipcodeapi.com - costs about $10/month but it’s rock solid. drop their javaScript snippet into your hubspot form settings and you’re done. way easier than dealing with messy api setups.
Built this for our company forms about 6 months back. Best solution I found was the Zippopotam.us API - it’s free, reliable for US zip codes, and doesn’t need any keys or registration. Here’s how it works: add some JavaScript to your HubSpot form that watches the zip code field. Someone types in their zip, it hits the API, and automatically fills the city and state fields. Took me maybe an hour to set up, and I’m not even great with JavaScript. Couple things to watch for - some zip codes cover multiple cities, so you’ll get the primary one back. I also added a short delay so it’s not firing API calls with every keystroke. Been running smooth on our forms and we definitely saw better completion rates after adding it.
Had this exact problem last year when I redesigned our registration forms. USPS Web Tools API + simple JavaScript function solved it perfectly. The API’s free and covers every valid US postal code since it’s straight from the source. You’ll need to register for an API key but it’s easy and they approve it fast. Best part? You’re getting data directly from USPS instead of some third-party database that’s probably outdated. Just add a blur event listener to your zip code field that hits the USPS endpoint and parses the XML response. Took me 30 minutes to set up and it’s been running flawlessly for over a year. The docs look terrible but the API’s rock solid and handles weird edge cases.
Honestly, APIs and custom JavaScript get messy for long-term maintenance. I’ve dealt with broken integrations when APIs change endpoints or require authentication updates.
I’d recommend automating this with Latenode instead. Set up a workflow that triggers when someone submits a HubSpot form with just a postal code. The automation grabs the zip, calls whatever postal lookup service you want (or multiple for backup), and updates the HubSpot contact record with city and state data.
You’re not dependent on frontend JavaScript that might break. Plus you can add logic for edge cases like multiple cities per zip, or fallback to a secondary API if the first fails.
I built something similar for our lead forms - it processes hundreds of submissions weekly without issues. Takes 15 minutes to set up and you never think about it again.
Check it out at https://latenode.com