hledger-accounts
Show account names from hledger journal file
TLDR
Show all accounts used or declared in the default journal file
Show accounts used by transactions
Show accounts declared with account directives
Add new account directives, for accounts used but not declared, to the journal
Show accounts with asset in their name, and their declared/inferred types
Show accounts of the Asset type
Show the first two levels of the accounts hierarchy
SYNOPSIS
hledger accounts [OPTIONS] [PATTERN]
PARAMETERS
--tree
Show a collapsible account name tree
--flat
Show a flat list of accounts (default with pattern)
--drop N
Show only the last N parts of each account name
--no-total
Hide the summary total line
--only
Show only accounts with postings (default)
-f --file FILE
Use additional journal files
--register
Show individual postings instead of accounts
-h --help
Show command help
DESCRIPTION
The hledger accounts command displays all account names appearing in the journal file(s) loaded by hledger, along with the number of postings to each account and the files where they appear. It provides a quick overview of the account structure in your plain text accounting data.
By default, accounts are shown in a hierarchical tree format based on their names (eg Equity:Opening Balances, Expenses:Food:Groceries), sorted alphabetically. Each account line includes: the full account name, posting count, and file names (truncated if long).
A PATTERN argument (a case-insensitive regex) can filter accounts, showing only matching ones. This is useful for exploring subsets, like all "Assets" accounts.
Options allow customising the view: --flat for a simple list without hierarchy; --tree for an interactive collapsible tree (in terminal); --drop N to shorten account names by dropping the first N parts; and more. It respects hledger's standard options like --file for custom journals.
This command is invaluable for data validation, refactoring account names, or generating account lists for reports. Output is precise and grep-friendly, aiding scripting.
CAVEATS
Output tree requires a capable terminal; patterns are regex and case-insensitive. Does not show unused accounts by default. Large journals may be slow without filtering.
EXAMPLE USAGE
hledger accounts Assets — lists all asset accounts.
hledger accounts --flat --drop 1 — flat list of account leaf names.
OUTPUT FORMAT
Each line: ACCTNAME (N) file.journal...
Summary shows total accounts and postings.
HISTORY
Part of hledger since v0.1 (2007), developed by Simon Michael. Evolved with tree/flat views in v0.20+; aligns with Haskell reimplementation for performance.
SEE ALSO
hledger(1), hledger-balance(1), hledger-print(1), ledger(1)


