🇹🇭 อ่านฉบับภาษาไทย →

Build a Search Page for Your Google Sheets Data with Apps Script in 15 Minutes

Turn a sheet with thousands of rows into a simple web page where anyone on your team can type and find what they need, without opening the sheet.

Kumron BoongetKumron Boonget
4 Dec 2026 · 1 min read

Ever had to open a huge sheet and press Ctrl+F to hunt for data cell by cell? If your team looks up the same data every day, you can give them a search page in a few minutes with Apps Script, which already comes with Google Sheets.

What you need

  • A Google Sheet with data, with column headers in the first row
  • A Google account (free)
  • About 15 minutes

This example uses a sheet named Data with the columns Product code, Product name and Stock.

1. Open Apps Script

In your sheet, go to Extensions → Apps Script. This opens a code editor linked to the sheet.

2. Write the server side (Code.gs)

Delete the existing code and paste this in its place.

js
function doGet() {
  return HtmlService.createHtmlOutputFromFile('Index')
    .setTitle('Search');
}

function search(q) {
  const sh = SpreadsheetApp.getActive().getSheetByName('Data');
  const data = sh.getDataRange().getDisplayValues();
  const head = data.shift();
  q = String(q || '').trim().toLowerCase();
  if (!q) return { head: head, rows: [] };
  const rows = data
    .filter(r => r.join(' ').toLowerCase().includes(q))
    .slice(0, 50); // show up to 50 rows
  return { head: head, rows: rows };
}

Tip Use getDisplayValues() instead of getValues() to get numbers and dates exactly as they look in the sheet, with no extra formatting needed.

3. Build the web page (Index.html)

Click + → HTML, name the file Index, and paste this code.

html
<!DOCTYPE html>
<html>
<body style="font-family:sans-serif;padding:16px">
  <input id="q" placeholder="Type to search..." style="width:100%;padding:10px">
  <div id="out"></div>
  <script>
    let t;
    document.getElementById('q').addEventListener('input', e => {
      clearTimeout(t);
      t = setTimeout(() => {
        google.script.run.withSuccessHandler(show).search(e.target.value);
      }, 300);
    });
    function show(res) {
      const esc = s => String(s).replace(/[&<>]/g, c => ({'&':'&amp;','<':'&lt;','>':'&gt;'}[c]));
      document.getElementById('out').innerHTML = res.rows.length
        ? '<table border=1 cellpadding=6><tr>' + res.head.map(h => '<th>' + esc(h) + '</th>').join('') + '</tr>' +
          res.rows.map(r => '<tr>' + r.map(c => '<td>' + esc(c) + '</td>').join('') + '</tr>').join('') + '</table>'
        : '<p>No results</p>';
    }
  </script>
</body>
</html>

The code waits until you stop typing for 0.3 seconds before searching, so it doesn't call the server on every keystroke.

4. Deploy as a web app

  1. Click Deploy → New deployment
  2. Choose the type Web app
  3. Execute as: Me / Who has access: pick what fits, e.g. Anyone within (your company domain)
  4. Click Deploy, then copy the link ending in /exec and share it with your team

Caution If you choose Anyone, everyone with the link can search all the data in the sheet. Don't use this for confidential data.

Taking it further

  • Search only specific columns instead of the whole row
  • Add filter buttons by status
  • Limit access to a list of emails stored in the sheet

In the next article, we'll look at restricting who can use the page.

#Apps Script#Web App
Kumron Boonget
Kumron Boonget

Operations professional at a container and ISO tank depot in Thailand. He builds the systems his team uses every day with Google Sheets, Apps Script and AppSheet, from search pages to repair tracking and automatic alerts, and shares how to build them in plain language for non-programmers.

Comments

No comments yet. Be the first to share your thoughts or ask a question.

Leave a comment
Comments are reviewed before they appear.

Read next