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 Boonget4 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.
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 ofgetValues()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.
<!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 => ({'&':'&','<':'<','>':'>'}[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
- Click Deploy → New deployment
- Choose the type Web app
- Execute as: Me / Who has access: pick what fits, e.g. Anyone within (your company domain)
- Click Deploy, then copy the link ending in
/execand 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.
Comments
No comments yet. Be the first to share your thoughts or ask a question.
Read next
Send Automatic Telegram Alerts When a New Row Is Added in Google Sheets
Whenever someone submits a form or adds a new job to your sheet, get a Telegram notification right away instead of checking the sheet yourself.
Stop Putting Secrets in Your Code! Store PINs and Tokens with Script Properties
Form PINs, bot tokens and API keys don't belong in your code. Here's a simple way to store them more safely.