How to Normalize a Street Address in JavaScript

Cloudmersive
1 min readJun 15, 2021

If your platform relies on user input for contact information, there is no guarantee that the format will meet the requirements of your internal programs. To ensure your system can successfully read and accept street addresses, you can use the following API to normalize and validate an input street address; if the address is valid, it will also provide the latitude and longitude coordinates.

To begin, run this command to install jQuery:

bower install jquery

Next, you can call the validation function with the below code:

var settings = {
"url": "https://api.cloudmersive.com/validate/address/street-address/normalize",
"method": "POST",
"timeout": 0,
"headers": {
"Content-Type": "application/json",
"Apikey": "YOUR-API-KEY-HERE"
},
"data": JSON.stringify({
"StreetAddress": "<string>",
"City": "<string>",
"StateOrProvince": "<string>",
"PostalCode": "<string>",
"CountryFullName": "<string>",
"CountryCode": "<string>"
}),
};
$.ajax(settings).done(function (response) {
console.log(response);
});

This will return a wealth of information about the address, if it is indeed valid. To retrieve your API key for the operation, head over to the Cloudmersive website to register for a free account; this provides 800 monthly calls across any of our APIs.

--

--

Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.