Jake Zhang

Migrating From Actual Budget SQLite to Firefly III Without Losing Transfers, Splits, or Balances

Most self-hosted finance migration guides go in one direction: leaving Firefly III for Actual Budget via per-account CSV exports.

When I moved the other direction, from Actual Budget into Firefly III, I quickly learned why CSV exports fall apart for double-entry ledgers:

  1. Transfers break or double-count. Actual stores a transfer as two linked rows (transferred_id) across two accounts. Export per-account CSVs and Firefly sees two unrelated transactions unless you hand-reconcile every pair.
  2. Split transactions flatten. Parent-child relationships vanish, leaving either an uncategorized total or disconnected sub-rows.
  3. Same-account transfers fail outright. Actual lets a transaction transfer back into the same account (a quirk that happens occasionally with imported statements or cleanups). Firefly III's API strictly rejects a transfer where source_id == destination_id.
  4. Refunds collide with merchant naming. If you bought something from a merchant (withdrawal) and later received a refund (deposit) under the same payee name, Firefly's separate expense and revenue account namespaces can make reports and rules messy unless you disambiguate them.
  5. Partial imports are miserable to recover from. If transaction #1,842 fails due to a validation error or timeout, re-running a naive importer duplicates the first 1,841 entries.

Instead of fighting CSV column mappers, I wrote a zero-dependency Python CLI, actual-to-firefly (available on PyPI), that reads Actual's unencrypted db.sqlite directly in read-only mode, talks cleanly to the Firefly III REST API, and reconciles every account balance down to the cent before exiting 0.

Reading Actual's SQLite Ledger Directly

Actual's local database is refreshingly clean once you filter out soft-deleted rows (tombstone = 0):

  • accounts: gives you offbudget (mapped cleanly to Firefly's include_net_worth = not offbudget) and closed (active = not closed).
  • transactions with starting_balance_flag = 1: rather than importing these as regular deposits, fold them into Firefly's native opening_balance and opening_balance_date on account creation.
  • category_groups and categories: flattened into "Group / Category", and any category with non-zero rows in zero_budgets gets a matching Firefly budget plus monthly budget limits.
  • Amounts are integer cents (amount in transactions and zero_budgets). Converting via Python's Decimal(cents) / Decimal(100) avoids float drift completely.

Five Edge Cases That Actually Bite You

1. Deduplicating Transfers Deterministically

In Actual, a transfer between Checking and Savings creates two rows pointing at each other via transferred_id. Ordering the pair IDs (sorted([row_id, other_id])) gives a single deterministic external_id:

actual-transfer:<min_id>:<max_id>

That solves two problems at once: each transfer posts once to Firefly III, and re-running the tool after an interruption skips it reliably.

What if one half of a transfer was tombstoned in Actual (transferred_id points to a missing row)? Rather than crashing with a KeyError, actual-to-firefly logs a structured warning in migration_report.json and imports the surviving row as a regular transaction so balances still reconcile.

2. Same-Account Transfers

When both halves of a transferred_id pair belong to the same Actual account, Firefly refuses a transfer payload. Splitting the pair into one balanced withdrawal (Self-transfer: <Account> (out)) and one deposit (Self-transfer: <Account> (in)) preserves both rows, keeps the net balance unchanged, and passes Firefly validation.

3. Split Transactions

Actual marks a split parent with isParent = 1 and child lines with isChild = 1, parent_id = <parent>. Two details matter here:

  • Skip parent rows when calculating expected balances (otherwise you double-count every split).
  • Firefly III requires every split inside a transaction group to share the same sign (all withdrawals or all deposits). If an Actual split mixes positive and negative child rows, failing closed with the exact parent ID is far better than silently distorting the ledger.

4. Dual-Role Payees and Asset Name Collisions

Two subtle Firefly III pitfalls:

  • If a payee name happens to match one of your own asset account names (for example, a bank fee whose payee is literally your account name), prefixing the counterparty with External: <name> prevents unintended account collisions.
  • If the same payee appears in both withdrawals and deposits (such as a store purchase plus a refund), actual-to-firefly detects dual-role payees automatically and appends (refund) to the revenue side by default (configurable via --refund-suffix or overridden via --counterparty-map).

5. Idempotency and Post-Import Balance Proof

Every run defaults to dry-run mode, reading db.sqlite with ?mode=ro and writing a full plan to migration_report.json without touching Firefly III.

When you pass --execute, every imported transaction carries a deterministic external_id. After posting, the tool re-fetches all Firefly accounts and transactions and checks two invariants:

  1. Exact balance equality: every account's firefly_balance - actual_budget_balance must equal 0.00.
  2. External ID completeness: zero planned external_ids missing from Firefly.

If either check fails, the CLI exits with status 1 and writes the exact diff table into migration_report.json.

Trying It Safely

# 1. Dry-run first (no Firefly token needed)
uvx actual-to-firefly \
  --actual-db /path/to/db.sqlite \
  --currency USD \
  --report migration_report.json

# 2. Execute against a test or fresh Firefly III instance
export FIREFLY_TOKEN="your-personal-access-token"
uvx actual-to-firefly \
  --actual-db /path/to/db.sqlite \
  --firefly-url https://firefly.example.com \
  --currency USD \
  --execute

Always test against a disposable Firefly III instance or database backup first. Rules, schedules, and attachments are intentionally out of scope. This tool focuses strictly on getting your historical ledger, budgets, transfers, and splits across with mathematical verification.

Code and issue tracker: github.com/JacobYZ/actual-to-firefly (MIT licensed, zero runtime dependencies, Python 3.11+).