How to automate a Trello board export to CSV

What Trello gives you out of the box

According to Trello's export documentation:

All of these are manual: someone opens the board menu and clicks Export. To get a CSV every week without anyone clicking, you have to schedule it yourself.

The free route: Trello API + Google Apps Script

The Trello REST API works on every plan. You can read a board's lists and cards, turn them into CSV rows and save the file to Drive on a timer.

Step 1: Get an API key and token

Create an API key through Trello's developer / Power-Up admin page, then generate a token for your account from that same page. The token can see every board your account can see, so treat it like a password.

Step 2: Find the board ID

Add .json to the end of the board URL, for example https://trello.com/b/AbC123/client-work.json. The id field at the top is the board ID. The short code in the URL (AbC123) usually works too.

Step 3: Write the script

In Google Apps Script, add TRELLO_KEY and TRELLO_TOKEN under Project Settings > Script properties, then paste in:

`js

function exportTrelloBoard() {

const p = PropertiesService.getScriptProperties();

const auth = 'key=' + p.getProperty('TRELLO_KEY') + '&token=' + p.getProperty('TRELLO_TOKEN');

const board = 'YOUR_BOARD_ID';

const get = path => JSON.parse(UrlFetchApp.fetch(

'https://api.trello.com/1/' + path + (path.indexOf('?') > -1 ? '&' : '?') + auth

).getContentText());

const lists = {};

get('boards/' + board + '/lists').forEach(l => lists[l.id] = l.name);

const cards = get('boards/' + board + '/cards?fields=name,idList,due,dateLastActivity,labels,shortUrl');

const rows = [['card', 'list', 'labels', 'due', 'last_activity', 'url']];

cards.forEach(c => rows.push([

c.name,

lists[c.idList] || '',

(c.labels || []).map(l => l.name).join('; '),

c.due || '',

c.dateLastActivity,

c.shortUrl

]));

const csv = rows.map(r => r.map(v => '"' + String(v).replace(/"/g, '""') + '"').join(',')).join('\n');

const name = 'trello-' + board + '-' + Utilities.formatDate(new Date(), 'UTC', 'yyyy-MM-dd') + '.csv';

DriveApp.getFolderById('YOUR_FOLDER_ID').createFile(name, csv, MimeType.CSV);

}

`

Step 4: Schedule it

Open Triggers in the Apps Script editor and add a time-driven trigger set to a weekly timer. Run it by hand once first so Google can ask for Drive permissions.

Adding more boards

Put the board IDs in an array and loop over them. You can write one file per board, or add a board column and write everything to one file. Agencies with a board per client usually find the single file easier to filter.

Pitfalls to watch

Other routes

A simple checklist

1. Decide the columns you actually need, such as card, list, labels, due date and client.

2. Get an API key and token, and store them in script properties, not in the code.

3. Run the script once by hand, then add a weekly trigger.

4. Every month, compare the CSV's card count with the board's card count.

We're building Sundayfile, a scheduled CSV backup app for agency teams. It's starting with HubSpot, so it doesn't do Trello yet. If you need Trello exports today, the script above is the most direct route.

Try it