Add address autocomplete to an existing field

Add US address autocomplete to an existing HTML input, with keyboard navigation and editable suggestions.

Last tested

Working example

HTML + form.js
JavaScript (browser)

Set up ParseAPI

Use a public API key restricted to your website. Keep secret keys on your server.

Get an API key ↗

Add address autocomplete

Help someone enter an address in your checkout or contact form. Include form.js once and mark the existing input with data-parse="address". Keep its label, name, and styles.

HTML
<script src="https://cdn.parseapi.com/v1/form.js?v=58c6b536b80c" data-key="YOUR_PUBLIC_API_KEY" data-parse-version="2.3.0" defer></script>
<input id="address" name="address" data-parse="address" placeholder="Start typing an address">

Suggestions appear as the person types. Click one, or use the arrow keys and Enter. The completed address stays in the same field and submits with your existing form.

Start typing

Type a house number and street. Add a city and state or ZIP in the same field to search a different place. This example supports US addresses; coverage varies by place.

The result is an address suggestion for the person to review. Keep it editable when suggestions are unavailable, and use a separate address-confirmation step if your application needs postal delivery verification.

Submit the selected address

The input's name="address" is the value your backend receives. Selecting a suggestion fills that same input; it does not create a new submission endpoint. Keep the person's final edited value with the rest of the form and validate it on your server before relying on it.

Build directly with the Address API when you need a custom integration.

Complete example

Use the complete implementation as a reference when adding this feature to your app. It includes the validation and failure handling around the calls above.

View and copy the complete source
address-autocomplete.html
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Address autocomplete</title>
  <style>
    :root { color-scheme: light dark; --bg: #fff; --ink: #152029; --muted: #5e6b75; --line: #d9e2e7; --field: #f6f9fa; --accent: #007c91; --error: #b42335; }
    @media (prefers-color-scheme: dark) {
      :root:not([data-theme="light"]) { --bg: #0b1015; --ink: #eff7fa; --muted: #94a6b2; --line: #2c3942; --field: #121b23; --accent: #67e8f9; --error: #fda4af; }
    }
    :root[data-theme="dark"] { color-scheme: dark; --bg: #0b1015; --ink: #eff7fa; --muted: #94a6b2; --line: #2c3942; --field: #121b23; --accent: #67e8f9; --error: #fda4af; }
    :root[data-theme="light"] { color-scheme: light; }
    * { box-sizing: border-box; }
    [hidden] { display: none !important; }
    body { margin: 0; padding: 24px; background: var(--bg); color: var(--ink); font: 15px/1.5 system-ui, sans-serif; }
    main { max-width: 540px; margin: 0 auto; }
    label { display: block; margin-bottom: 8px; font-size: 14px; font-weight: 600; }
    input { display: block; width: 100%; min-width: 0; padding: 13px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--field); color: var(--ink); font: inherit; }
    input::placeholder { color: var(--muted); }
    input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
    /* Your form owns these styles. form.js adds semantic markup and states. */
    input[data-parse-status="invalid"], input[data-parse-status="disposable"] { border-color: var(--error); }
    .parse-hint { margin: 6px 0 0; color: var(--muted); font-size: .875em; line-height: 1.4; overflow-wrap: anywhere; }
    .parse-hint[data-parse-status="invalid"], .parse-hint[data-parse-status="disposable"] { color: var(--error); }
    .parse-hint-suggestion { padding: 0; border: 0; background: none; color: inherit; font: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
    .parse-hint-suggestion:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
    .parse-address-suggestions { margin: 6px 0 0; padding: 0; list-style: none; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); font: inherit; overflow: hidden; }
    .parse-address-suggestions li { padding: 10px 14px; cursor: pointer; overflow-wrap: anywhere; }
    .parse-address-suggestions li + li { border-top: 1px solid var(--line); }
    .parse-address-suggestions .street { display: block; font-weight: 500; }
    .parse-address-suggestions .place { display: block; margin-top: 2px; color: var(--muted); font-size: .8em; }
    .parse-address-suggestions li[aria-selected="true"], .parse-address-suggestions li:hover { background: color-mix(in srgb, var(--accent) 12%, var(--bg)); }
    @media (max-width: 380px) { body { padding: 18px; } }
  </style>
</head>
<body>
  <main>
    <label for="address">Address</label>
    <!-- example:form -->
    <script src="https://cdn.parseapi.com/v1/form.js?v=58c6b536b80c" data-key="YOUR_PUBLIC_API_KEY" data-parse-version="2.3.0" defer></script>
    <input id="address" name="address" data-parse="address" placeholder="Start typing an address">
    <!-- /example:form -->
  </main>
</body>
</html>
Try the complete example on your computer

Replace YOUR_PUBLIC_API_KEY in the HTML with your public key and add localhost to its allowed domains. Serve the download folder over HTTP:

Terminal · Python 3
python3 -m http.server 8000

Open localhost:8000/address-autocomplete.html. Add your website's hostname to the key when using the feature there.

For every field and parameter, see Address API reference.