PasteSheet icon PasteSheet logo mark — a spreadsheet grid with a curly brace on a green rounded square PasteSheet

Convert a Google Sheet to SQL inserts

Paste a Google Sheet URL and get a CREATE TABLE statement and a batch of INSERTs back — column names normalised, types guessed from your data, and string values escaped so that a stray apostrophe cannot break the script.

The sheet must be shared with "Anyone with the link". Nothing is stored.

Key facts

  • Google's API requires a Google Cloud project plus OAuth credentials or a service account before it will return a single row. source
  • Google's Sheets API is cell-oriented: it reads ranges like A1:D50, not records. Reassembling those into row objects is work you do yourself. source
  • The Google Sheets API allows 300 read requests per minute per project and 60 per minute per user. Past that it returns 429 RESOURCE_EXHAUSTED. source
  • It needs no Google Cloud project, no OAuth consent screen and no service-account JSON. You paste a share URL, and MCP is included on the Free plan.

How to convert a Google Sheet to SQL

  1. 1 In Google Sheets, click Share, then set General access to Anyone with the link (Viewer is enough). If you skip this, the tool cannot read the sheet — check whether yours is public.
  2. 2 Copy the sheet URL from your browser's address bar. To use one specific tab, open that tab first so its gid ends up in the URL.
  3. 3 Paste it above. Header names are normalised to snake_case identifiers, and each column's type is inferred by looking at its values.
  4. 4 Copy the SQL, review the inferred types, and run it against your database.

What the output looks like

sheet.sql
CREATE TABLE sheet_data (
  name TEXT,
  role TEXT,
  headcount INTEGER
);

INSERT INTO sheet_data (name, role, headcount) VALUES
  ('Ada Lovelace', 'Engineer', 12),
  ('Grace Hopper', 'Admiral', 40),
  ('D''Arcy Thompson', 'Biologist', 3);

What it does to your data

  • Quotes are escaped. A value like D'Arcy becomes 'D''Arcy' — the SQL standard doubling — so an apostrophe in your data cannot terminate the string early or turn into an injection footgun.
  • Column names are normalised. First Name becomes first_name. Anything that is not a letter, digit or underscore is replaced, and a name starting with a digit is prefixed, so every identifier is legal.
  • Types are inferred, not assumed. A column whose values are all integers becomes INTEGER; all numeric becomes NUMERIC; anything else stays TEXT. An empty cell becomes NULL.
  • Portable by default. The output sticks to standard SQL that MySQL, PostgreSQL and SQLite all accept. Review the types before running it in production — a guess from data is a guess.

If you are doing this repeatedly, do not

Generating inserts is the right move for a one-off import — seeding a dev database, moving a lookup table into Postgres once. It is the wrong move as a routine: every time the sheet changes you regenerate, re-run, and hope nobody edited it in between.

What you get above is a snapshot: it reflects the sheet as it is right now. Edit a cell and the file you downloaded is out of date, and you run the conversion again. A PasteSheet endpoint is the same data at a URL that stays current — it re-reads the sheet on your schedule and serves whatever is in it now, so your app or AI agent never reads a stale export.

What a live endpoint costs

Nothing, to start. The Free plan gives you 3 endpoints and 2,000 requests a month, with MCP included and no credit card. The tool above stays free and unlimited either way.

Free

For side projects and trying things out.

$0 /mo
Endpoints
3
Requests / mo
2,000
Row cap
500
  • MCP for AI agents

Frequently asked questions

Does my Google Sheet need to be public?

It needs to be readable by anyone with the link. In Google Sheets, click Share and set General access to "Anyone with the link". A sheet left as "Restricted" cannot be read by this tool, or by anything else that has not been explicitly granted access to it.

Can I use one specific tab?

Yes. Open the tab you want in Google Sheets and copy the URL from the address bar — it will contain a gid parameter identifying that tab. Paste that URL and the tool reads that tab rather than the first one.

Do you store my sheet or its data?

No. The rows are fetched, converted and handed back to you. The result is cached for about a minute so that a reload does not re-hit Google, and then it is gone. Nothing is written to a database and nothing is shared with anyone.

Which SQL dialect does it generate?

Standard SQL that MySQL, PostgreSQL and SQLite all accept: a plain CREATE TABLE with TEXT, INTEGER and NUMERIC types, and multi-row INSERT ... VALUES. There is nothing dialect-specific in the output, so it runs anywhere without editing.

How are apostrophes and quotes escaped?

Single quotes in a value are doubled, which is the SQL standard escape — so D'Arcy becomes 'D''Arcy'. That is what stops a stray apostrophe from terminating the string early and breaking, or worse, altering the meaning of the statement.

Are the column types reliable?

They are inferred from the values in the sheet, so treat them as a starting point and review them. A column of integers becomes INTEGER, a column of numbers becomes NUMERIC, and everything else stays TEXT — which is safe but may be looser than you want.

Sources

Related tools

Turn your sheet into an API in minutes

Paste a Google Sheet URL and get a live REST API and MCP server — no backend, no code, free to start.