How to automate a Trello board export to CSV
What Trello gives you out of the box
According to Trello's export documentation:
- Any board member can export a board as JSON, on any plan.
- CSV export is for boards in Premium Workspaces. With Premium, a Workspace admin can also export every board in the Workspace.
- The CSV export does not include comments. The JSON export includes the 1,000 most recent actions on the board, comments included.
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
- Archived cards. By default the board's cards endpoint returns only open cards. If you want a real backup that includes archived work, use the
filterparameter on that endpoint (see Trello's API reference). - Custom fields and checklists aren't included in the basic card fields. You'll need extra calls for them. Decide whether you actually need them before you add more code.
- Comments live in the board's actions, not on the card object. If comments matter for your records, store the raw JSON export as well as the CSV.
- Formula injection. A card title that starts with
=can be read as a formula when the CSV is opened in a spreadsheet. If clients can create cards, add a'in front of those values. - Rate limits. Trello limits API requests. A few boards a week won't come close, but a script that loops over hundreds of boards might.
- Token owner. The script sees only the boards that the token's owner can see. If that person is removed from a board or leaves the company, the export quietly stops covering it.
Other routes
- Upgrade to Premium if you only need an occasional manual CSV and your team can stay disciplined about doing it.
- Automation platforms like Zapier or Make can send Trello events to a spreadsheet. Check whether they can take a full weekly snapshot or only record changes, because those are different things.
- Power-Ups in Trello's own directory offer exporting and reporting from inside the board.
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.