Claude Code for Google Sheets: Clean, Analyse, Automate
Claude Code for Google Sheets covers the spreadsheet work most operators dread: cleaning messy exports, figuring out the right formula, summarising thousands of rows and automating the copy-paste you do every week. Claude Code handles all of it in plain English.
Claude Code for Google Sheets means using an AI agent on your spreadsheet data: export a sheet into a folder for cleaning and analysis, get formulas with explanations, or have it write Apps Script to automate the sheet. For live edits inside Sheets, Claude's Google connectors are simpler.
Here are the four ways to work, from simplest to most automated.
Four ways to work with Sheets
- 1
Export and analyse
download as CSV, ask questions, get answers
- 2
Formulas
the right formula for your sheet, explained
- 3
Apps Script
code that automates the sheet itself
- 4
Live connection
edits inside Sheets through a connector or API
1. Export, clean and analyse
The simplest and safest way. In Google Sheets choose File, Download, then CSV or Excel, and save it into a Claude Code folder. Then ask in plain English:
Read exports/leads.csv. Remove duplicate rows by email, standardise
phone numbers and states, flag rows with missing emails, and save a
clean copy as exports/leads-clean.csv. Then tell me how many leads we
have per source and per month.Claude Code writes and runs the analysis itself and shows the numbers it used, so you can check them before importing the clean file back into Sheets. Good jobs for this route:
- Deduplicating and standardising lists.
- Summaries by month, source, product or rep.
- Spotting rows that look wrong.
- Merging two exports on a shared column.
2. Formulas you understand
Describe what you want and paste a few sample rows with the column letters. Ask for the formula and a one-line explanation of each part. Useful for the formulas people avoid: QUERY, XLOOKUP, FILTER, ARRAYFORMULA and nested IFs. Ask for a version that handles blanks and errors, too.
A good habit: ask for the formula, then ask Claude Code to explain what would break it. Formulas fail on blank rows, text where a number should be, extra spaces and dates stored as text. Knowing the failure cases up front saves an hour of debugging later, and you can ask for a version wrapped in IFERROR or IFNA so one bad row does not break the whole column.
3. Apps Script automations
Google Sheets has a built-in scripting language, Apps Script, under Extensions, Apps Script. Claude Code can write the script for you:
- Copy new form responses into a tidy tab.
- Send a summary email every Monday from a report tab.
- Add a custom menu that formats a raw export in one click.
- Pull data from another tool's API on a schedule.
Paste the script into the Apps Script editor, run it once on a copy of your sheet, and approve the permissions it asks for only if they match what the script does.
4. A live connection
When you want edits to happen inside the sheet itself:
- In the Claude app: Claude's Google connectors can read Sheets through Google Drive, and a Sheets connector (in beta) can create and edit spreadsheets live. You switch them on under the connectors menu in a chat.
- In Claude Code: connect through the Google Sheets API with an MCP server or a small script. Start read-only, use a test copy of the sheet, and widen access only when you trust the setup.
A worked example: a messy lead export
Here is a common job from start to finish. The data is made up.
exports/leads.csv (fictional, 1,240 rows)
- Columns: Name, email, Phone, State, Source, Created
- Duplicate emails, phone numbers in five formats,
states written as "TX", "Texas" and "tx"
- Some rows missing email, dates as textRead exports/leads.csv. Remove duplicate rows by email (keep the newest),
standardise phone numbers to (555) 555-5555 and states to two-letter
codes, convert Created to real dates, and move rows with no email to a
separate file. Save leads-clean.csv and leads-no-email.csv. Then show
leads per source per month as a table, and list anything that looks off.What comes back is two clean files and a short report: how many duplicates were removed, how many rows had no email, a source-by-month table, and a note like "41 rows have a Created date in the future, probably a time zone or entry error". You import the clean file into a new tab, spot-check a dozen rows against the original, and you are done in minutes rather than an afternoon.
When to use which approach
- Use an export for anything one-off or large: cleaning, merging, analysis. It is the safest, because the live sheet is untouched until you import.
- Use formulas when the sheet needs to stay live and anyone on the team should be able to read how a number is calculated.
- Use Apps Script for anything you do on a schedule or want behind one click, such as weekly summaries or formatting raw imports.
- Use a live connection only when you trust the setup and edits really need to happen inside the shared sheet.
Mistakes to avoid
- Running a script on the only copy. Duplicate the sheet first, every time.
- Trusting totals without checking. Ask for the rows behind any number you are going to act on.
- Granting broad permissions. An Apps Script should ask only for the access its job needs.
- Pasting sensitive data you do not need. Strip personal or financial columns before analysis if the job does not require them.
- Mixing raw and clean data in one tab. Keep the original export untouched and work in a separate clean tab.
Rules for spreadsheet work
- Work on a copy. Run any cleaning or script on a duplicate of the sheet first.
- Check the numbers. Ask Claude Code to show the rows behind any total that matters before you rely on it.
- Keep sensitive data out unless you need it: personal details, financial data and anything your policies restrict.
- Read script permissions. An Apps Script asking for far more access than its job needs is a red flag.
Claude Code for Google Sheets: FAQ
Is there an AI agent for Google Sheets?
Several AI tools work with Google Sheets. Claude can read and edit Sheets through its Google connectors in the Claude app, and Claude Code can analyse exported sheets, write formulas and build Apps Script automations.
What is the best AI for Google Sheets?
The best AI for Google Sheets depends on the job: built-in assistants are quickest for small edits inside a sheet, while Claude Code is stronger for cleaning large exports, multi-step analysis and writing automations.
Can you code with Google Sheets?
You can code with Google Sheets using Apps Script, Google's built-in scripting language, under Extensions, Apps Script. Claude Code can write those scripts from a plain-English description.
Is there a Google version of Claude Code?
Google has its own coding agent for the terminal, Gemini CLI, which I covered when it launched. Claude Code works with Google files through exports, connectors and the Sheets API.
Can Claude read a Google Sheet directly?
Claude can read a Google Sheet through its Google Drive connector in the Claude app, and Claude Code can read a sheet you export as CSV or Excel. For live edits from Claude Code, use the Google Sheets API with an MCP server or a script.
Can Claude Code make charts in Google Sheets?
Claude Code can build charts in an Excel file or write Apps Script that adds charts to a Google Sheet. For a quick one-off chart, ask for the data summarised into a small table and insert the chart in Sheets yourself.
Get the operator workspace
The AI Operator Kit saves lead lists, follow-up logs and reports as files you can open in Sheets, and includes a back-office command for invoice tracking and a 13-week cash forecast. New to the tool? Start with my guide to Claude Code for business owners.