I want to auto fill state and City. When i enter zip code in magento 2 checkout shipping address.

2 Answers 2


This functionality doesn't come out of box with Magento 2 but you can implement this. You'll need to add all the pincodes in a table with State and City name.
You might get this list online or APIs are also available to do so.
I'll prefer to store this data on your database as this will be a constant information and will give you better performance and control.
Then create a ajax controller to return city and state information based on given pincode which you can fetch from db or API.
Write js function to update the form.

I hope this will be helpful.
Let me know if you stuck somewhere in implementation.


There is a plugin called Wezz Postcodem2 (https://github.com/wezzco/postcode-m2) but that one only works for addresses in the Netherlands.

You could look into Google Address Magento 2 plugins but as i have seen most of them support only auto completion for Streetname. I haven't looked to far into it so maybe it does have some kind of possibility for the function you want.

  • Can you please give me link of Wezz Postcodem2?
    – Magecode
    Apr 30, 2019 at 11:59
  • @Magecode I added the link.
    – Sanne
    May 1, 2019 at 12:05
  • Thank you so much
    – Magecode
    May 2, 2019 at 13:10

Not the answer you're looking for? Browse other questions tagged or ask your own question.