Home

How to export a Xero trial balance to CSV that actually balances

This tool pulls the trial balance from Xero's own reporting API and refuses to write the CSV unless both the month's movement and the year to date figures balance. It asks Xero for report reading scope only, so it cannot write anything back to a ledger.

The manual path, Reports, Trial Balance, Export, fix the header rows, fix the account codes, takes about ten minutes per entity per month and produces a slightly different file every time. This tool pulls the same report straight from Xero's own reporting API instead, into the same tidy shape every run.

Before anything is written to disk, it runs a balance check: both the current month's movement and the year to date figures must balance, or no file is written at all. Note the real limit: --date is an as-at date, not a range, because Xero's Trial Balance endpoint only accepts a date, so Trial Balance by Date Range, a report that exists in the Xero interface only, cannot be reproduced this way. The movement columns already cover the usual reason someone reaches for a range: the current month.

It is read-only. The scope it asks Xero for is report reading only, so it cannot write anything back to your ledger.

What this tool does

Limits

Read-only (accounting.reports.trialbalance.read); this tool cannot write to any ledger.

MIT-licensed utility code, no warranty; outputs feed professional review like any other workpaper input. Not affiliated with or endorsed by Xero.

Get it

python -m pip install --require-hashes -r requirements.lock

Source on GitHub

Common questions

Can it export a trial balance for a date range?

No. Xero's Trial Balance endpoint accepts an as-at date, not a range, so the Trial Balance by Date Range report, which exists in the Xero interface only, cannot be reproduced this way. The movement columns cover the usual reason for wanting a range, which is the current month.

Can this tool change my Xero data?

No. It requests the accounting.reports.trialbalance.read scope, which is read-only, so it cannot write to any ledger.

What happens if the trial balance does not balance?

No file is written. The balance check runs before anything reaches disk, and both the month's movement and the year to date figures have to balance for the export to proceed.

Related

Published 24 August 2026. Last reviewed 24 August 2026.

Written independently by Ryan Duguid, a provisional member of Chartered Accountants ANZ, in his own time and on his own equipment.