Export an Airtable view to CSV with a script (code included)
If you're comfortable with a little JavaScript, Airtable's scripting can turn a view into CSV text in about 30 lines. Below is a snippet that keeps the view's filters and sort order, writes the columns you choose, and escapes values properly.
The script
Paste this into a Scripting extension (or an automation's Run script action) and change the table and view names.
const table = base.getTable('Orders');
const view = table.getView('Export - do not edit');
// List the columns you want, in order. Scripting can't read which fields a view hides.
const fields = ['Order ID', 'Customer', 'Status', 'Total'].map((n) => table.getField(n));
const query = await view.selectRecordsAsync({ fields });
function cell(v) {
let s = v == null ? '' : String(v);
if (/^[=+\-@\t\r]/.test(s) && isNaN(Number(s))) s = "'" + s; // formula-injection guard
return /[",\r\n]/.test(s) ? '"' + s.replace(/"/g, '""') + '"' : s;
}
const rows = [fields.map((f) => cell(f.name)).join(',')];
for (const r of query.records) {
rows.push(fields.map((f) => cell(r.getCellValueAsString(f))).join(','));
}
const csv = '\uFEFF' + rows.join('\r\n'); // BOM so Excel reads UTF-8
output.text(`${query.records.length} records, ${csv.length} characters`);
What each part does
selectRecordsAsyncon a view returns records with that view's filters and sort applied, with no 100-record limit.getCellValueAsStringgives the same text you see in the grid for linked records, lookups, dates and selects.- The
cellfunction quotes values with commas, quotes or line breaks, and prefixes text that starts with=,+,-or@so spreadsheets don't run it as a formula. - The leading
\uFEFFis a UTF-8 byte-order mark; without it, Excel on Windows often garbles accents.
Running it on a schedule
In the Scripting extension the script only runs when someone clicks Run. For a schedule, put it in an automation with an At a scheduled time trigger. The catch: an automation can't attach the resulting text as a file to its own Send email action. You'd post the CSV to an external email API (SendGrid, Mailgun, Postmark) from the script, which means an extra account and an API key sitting in your base. Automation scripts also have time and memory limits, so very large views may need batching.
When to skip the script
If the goal is "this view, as a CSV, in these inboxes, every Monday at 8", a dedicated tool saves you the email API, the key management and the failure handling. ViewCourier runs the export from a read-only token, sends the CSV as an attachment and emails you if a run fails. For a one-off export of every table, the free Airtable base to CSV tool runs in your browser.
Let ViewCourier do it
Connect a read-only Airtable token, pick a view, and choose daily, weekly or monthly at your time and timezone. Every run emails a clean CSV attachment to up to five people. The free trial lasts 14 days and needs no credit card.
More guides
- How to export an Airtable view to CSV automatically
- How to email an Airtable view on a schedule (daily, weekly, monthly)
- Automatic Airtable backups to CSV: options and limits
- How to send a scheduled Airtable export to Excel users
- A simpler alternative to Zapier and Make for Airtable CSV exports
- How to send a weekly Airtable report to clients or your manager
- Airtable CSV export tools compared (2026): EasyCSV, On2Air, CSV Getter, Make, ViewCourier
- On2Air alternative for scheduled Airtable CSV exports by email
- EasyCSV alternative for emailing Airtable views as CSV
- Can an Airtable automation email a CSV attachment? (And what to do instead)
- How to email more than 100 Airtable records at once
- Free tool: export an entire Airtable base to CSV
- Free tool: export an Airtable base schema (field list)