Get a Maps Demo Key: Try out select Maps JavaScript API and Places UI Kit features at no cost with a Maps Demo Key—no billing information required.

Validate an address

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}`);
}

Next steps

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026年09月01日 UTC.