Stay organized with collections
Save and categorize content based on your preferences.
To validate an address using Address Validation in Maps JavaScript API, call the fetchAddressValidation
method passing a request body with the address to validate, as shown in the following example.
asyncfunctionvalidateAddress(){// Import the Address Validation library.const{AddressValidation}=awaitgoogle.maps.importLibrary('addressValidation');// Call the fetchAddressValidation method.constresult=awaitAddressValidation.fetchAddressValidation({address:{postalCode:'94043',regionCode:'US',languageCode:'en',addressLines:['1600 Amphitheatre','Parkway'],}});// Log the results to the console.document.querySelector('pre').textContent=JSON.stringify(result,null,' ');}
You can define an address by using individual components, or by using addressLines
to pass the entire formatted address as an array literal (the API will parse the address
into individual components):
address:{addressLines:['1600 Amphitheatre Parkway, Mountain View, CA 94043'],}
Handle the results
The fetchAddressValidation method returns a promise that resolves to an
AddressValidationResponse object. This object contains the validated address,
including any corrections made by the API. You can access the various fields of the
response object to determine the validation status of the address. The following example
shows how to access the fields of the response object.
asyncfunctionvalidateAddress(){// Import the Address Validation library.const{AddressValidation}=awaitgoogle.maps.importLibrary('addressValidation');// Call the fetchAddressValidation method.constresult=awaitAddressValidation.fetchAddressValidation({address:{postalCode:'94043',regionCode:'US',languageCode:'en',addressLines:['1600 Amphitheatre','Parkway'],}});// Log the results to the console:console.log(`Formatted address: ${result.address.formattedAddress}`);console.log(`Entered: ${result.verdict.inputGranularity}`);console.log(`Validated: ${result.verdict.validationGranularity}`);console.log(`Address complete: ${result.verdict.addressComplete}`);console.log(`Has unconfirmed components: ${result.verdict.hasUnconfirmedComponents}`);console.log(`Has inferred components: ${result.verdict.hasInferredComponents}`);console.log(`Has replaced components: ${result.verdict.hasReplacedComponents}`);}
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-18 UTC."],[],[],null,["| This product or feature is in Preview (pre-GA). Pre-GA products and features might have limited support, and changes to pre-GA products and features might not be compatible with other pre-GA versions. Pre-GA Offerings are covered by the [Google\n| Maps Platform Service Specific Terms](https://cloud.google.com/maps-platform/terms/maps-service-terms). For more information, see the [launch stage\n| descriptions](/maps/launch-stages).\n\n\nTo validate an address using Address Validation in Maps JavaScript API, call the `fetchAddressValidation`\nmethod passing a request body with the address to validate, as shown in the following example. \n\n```javascript\nasync function validateAddress() {\n // Import the Address Validation library.\n const {AddressValidation} =\n await google.maps.importLibrary('addressValidation');\n // Call the fetchAddressValidation method.\n const result = await AddressValidation.fetchAddressValidation({\n address: {\n postalCode: '94043',\n regionCode: 'US',\n languageCode: 'en',\n addressLines: ['1600 Amphitheatre', 'Parkway'],\n }\n });\n // Log the results to the console.\n document.querySelector('pre').textContent =\n JSON.stringify(result, null, ' ');\n}\n \n```\n\nYou can define an address by using individual components, or by using `addressLines`\nto pass the entire formatted address as an array literal (the API will parse the address\ninto individual components): \n\n```javascript\naddress: {\n addressLines: ['1600 Amphitheatre Parkway, Mountain View, CA 94043'],\n}\n \n```\n\nHandle the results\n\nThe `fetchAddressValidation` method returns a promise that resolves to an\n`AddressValidationResponse` object. This object contains the validated address,\nincluding any corrections made by the API. You can access the various fields of the\nresponse object to determine the validation status of the address. The following example\nshows how to access the fields of the response object. \n\n```javascript\nasync function validateAddress() {\n // Import the Address Validation library.\n const {AddressValidation} =\n await google.maps.importLibrary('addressValidation');\n // Call the fetchAddressValidation method.\n const result = await AddressValidation.fetchAddressValidation({\n address: {\n postalCode: '94043',\n regionCode: 'US',\n languageCode: 'en',\n addressLines: ['1600 Amphitheatre', 'Parkway'],\n }\n });\n // Log the results to the console:\n console.log(`Formatted address: ${result.address.formattedAddress}`);\n console.log(`Entered: ${result.verdict.inputGranularity}`);\n console.log(`Validated: ${result.verdict.validationGranularity}`);\n console.log(`Address complete: ${result.verdict.addressComplete}`);\n console.log(`Has unconfirmed components: ${result.verdict.hasUnconfirmedComponents}`);\n console.log(`Has inferred components: ${result.verdict.hasInferredComponents}`);\n console.log(`Has replaced components: ${result.verdict.hasReplacedComponents}`);\n}\n \n```\n\nNext steps\n\n- [Understand a basic address validation response](/maps/documentation/javascript/address-validation/understand-response)"]]