sheet-exporter

A lightweight HTTP API that converts public Google Sheets into JSON or raw CSV.

Usage

Get JSON

GET /json/:sheetId
GET /json/:sheetId?gid=123456789

Returns a JSON object with link (a link back to the source sheet) and data (an array of objects keyed by column headers).

curl https://sheet-json.val.run/json/1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgVE2upms
{ "link": "https://docs.google.com/spreadsheets/d/1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgVE2upms/edit?gid=0", "data": [ { "name": "Alice", "age": "30" }, { "name": "Bob", "age": "25" } ] }

Get raw CSV

GET /csv/:sheetId
GET /csv/:sheetId?gid=123456789

Returns the raw CSV text exported from Google Sheets.

curl https://sheet-json.val.run/csv/1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgVE2upms

Parameters

  • :sheetId — The Google Sheet ID from the URL (e.g., 1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgVE2upms)
  • gid (optional) — The tab/sheet ID. Defaults to 0 (first tab). Find this in the sheet URL after #gid=.

Redirect

Requests to sheet.val.run are automatically redirected to sheet-json.val.run, preserving the original pathname. This is handled by redirect.ts.

For example, https://sheet.val.run/json/abc123 redirects to https://sheet-json.val.run/json/abc123.

Requirements

  • The Google Sheet must be publicly accessible ("Anyone with the link" sharing).
  • Private sheets will return an error.

Endpoints

main.tssheet-json.val.run

RouteDescription
GET /Health check — returns { "ok": true }
GET /json/:sheetIdFetch sheet as parsed JSON
GET /csv/:sheetIdFetch sheet as raw CSV text
GET /sourceRedirect to val source code

redirect.tssheet.val.run

RouteDescription
GET *Redirects all requests to sheet-json.val.run

Architecture

Rendering mermaid diagram...