Plain Text Accounting is Pretty Cool

Plain Text Accounting is Pretty Cool

纯文本记账(Plain Text Accounting)真的很酷

I like to keep track of my finances pretty religiously. I don’t really budget, I am just very obsessive about tracking every expense, and ensuring that my overall savings rate is high. I started by using Mint (may it rest in peace) and when it got killed, I switched to Rocket Money. Eventually I got annoyed with that due to it not supporting connections to some of my accounts and I ended up keeping track of my finances manually in markdown files in a git repo for a few years. 我一直非常虔诚地记录自己的财务状况。我其实并不怎么做预算,只是对追踪每一笔支出有着近乎强迫症般的执着,并确保我的整体储蓄率保持在高位。我最初使用的是 Mint(愿它安息),在它被关闭后,我转用了 Rocket Money。最终,由于它无法连接到我的一些账户,我感到很烦恼,于是有几年时间,我通过 git 仓库中的 Markdown 文件手动记录财务状况。

Last year, I started using Origin, which was pretty good. However, recently I started looking for a new solution due to a few reasons: 去年,我开始使用 Origin,它相当不错。然而,最近我开始寻找新的解决方案,原因如下:

  • Origin (like Rocket Money and Mint before it) has issues staying connected to all my accounts reliably. I consider periodically unreliable connections to be significantly more annoying than having to do manual entry of every financial transaction.

  • Origin(和之前的 Rocket Money 及 Mint 一样)在稳定连接我所有账户方面存在问题。我认为周期性的连接不稳定,比手动输入每一笔财务交易要烦人得多。

  • Origin does not handle closed accounts very well (closed credit cards/bank accounts/loans).

  • Origin 对已关闭账户(如已注销的信用卡、银行账户或已结清的贷款)的处理并不理想。

  • Origin does not allow me to track gross income and count payroll deductions towards my 401(k) as savings. As someone who is fortunate enough to be able to max out my 401(k), this really affects my monthly savings rate calculations.

  • Origin 不允许我追踪总收入,并将工资扣除的 401(k) 部分计入储蓄。作为一个有幸能存满 401(k) 的人,这确实影响了我每月储蓄率的计算。

  • One of the benefits that is included in the Origin subscription is free tax returns. However, they don’t support one of the situations that I had this year, so I wasn’t able to take advantage of that service and ended up having to pay for a different service anyway.

  • Origin 订阅包含的一项福利是免费报税。然而,他们不支持我今年遇到的某种特定情况,所以我无法利用这项服务,最终还是不得不付费使用了其他服务。

  • Origin keeps trying to AI-ify everything. I’ve tried asking questions of the AI for various financial situations, but its responses have been kinda obvious and uninsightful at best. I already pay $20/mo for a Claude subscription which has actually been more helpful with sorting out a few weird financial situations I’ve found myself in the last year.

  • Origin 一直试图将一切“AI 化”。我曾尝试就各种财务状况向其 AI 提问,但它的回答充其量只是显而易见且缺乏洞察力。我已经每月支付 20 美元订阅 Claude,它在处理我去年遇到的一些棘手财务状况时,实际上更有帮助。

In addition, I wanted to convert my personal finances to use double-entry bookkeeping for learning purposes. Double-entry bookkeeping is slightly unintuitive if you are unfamiliar with it (as I was when I started this journey), but once you get used to it, it’s pretty straightforward. I’m going to assume in the rest of this post that you have a basic understand of double-entry bookkeeping. 此外,出于学习目的,我想将个人财务管理转换为复式记账法。如果你不熟悉复式记账法(我刚开始这段旅程时也不熟悉),它会显得有些反直觉,但一旦习惯了,就会发现它非常直观。在本文的后续部分,我将假设你对复式记账法有基本的了解。

I briefly considered moving back to markdown files, and using AI to help me build better automation of the monthly net worth calculations (which was the most annoying part of the markdown file method). I asked Claude to do some research into best practices, and it surfaced an option that I hadn’t even heard of: plain text accounting. 我曾短暂考虑过回到使用 Markdown 文件的老路,并利用 AI 帮助我构建更好的自动化工具来计算每月净资产(这是 Markdown 文件法中最烦人的部分)。我让 Claude 研究了一些最佳实践,它提出了一个我从未听说过的选项:纯文本记账(Plain Text Accounting)。

Plain Text Accounting

纯文本记账

Plain Text Accounting (PTA) is an umbrella term for storing accounting data with plaintext files. This can get tedious (as I discovered from my years of using markdown files) so plain text accounting generally is also associated with using software tools to modify and report on the underlying plaintext files. Most plain text accounting programs use double-entry accounting at their core. 纯文本记账(PTA)是一个统称,指使用纯文本文件存储会计数据。这可能会变得繁琐(正如我多年使用 Markdown 文件的经验所发现的那样),因此纯文本记账通常也与使用软件工具来修改和报告底层纯文本文件相关联。大多数纯文本记账程序的核心都使用复式记账法。

Of course, since it’s plain text, you don’t need to use any tools at all or you can easily create your own tooling. You can use a simple text editor to edit the source files. You can create custom programs to manipulate or report on your financial data. You can even take advantage of the fact that plain text is AI-native and use something like Claude Code to analyse your finances for insights. 当然,由于它是纯文本,你完全不需要使用任何工具,或者可以轻松创建自己的工具。你可以使用简单的文本编辑器来编辑源文件。你可以创建自定义程序来处理或报告你的财务数据。你甚至可以利用纯文本是“AI 原生”这一事实,使用像 Claude Code 这样的工具来分析你的财务状况并获取洞察。

Plain text also has the advantage that you can easily store the files in source control. In my case, I use a git repo that stores all my financial data. 纯文本的另一个优势是你可以轻松地将文件存储在版本控制系统中。就我而言,我使用一个 git 仓库来存储我所有的财务数据。

After some further research, I landed on using hledger. It’s written in Haskell, seems very well supported by the community, has built-in tools for importing transaction CSVs, and I like its journal file format. 经过进一步研究,我决定使用 hledger。它是用 Haskell 编写的,似乎得到了社区的良好支持,拥有用于导入 CSV 交易记录的内置工具,而且我很喜欢它的日记账文件格式。

In hledger, you create journal files to record journal entries (transactions) with a fairly straightforward syntax. Here is an example journal entry: 在 hledger 中,你通过创建日记账文件来记录分录(交易),其语法相当直观。以下是一个分录示例:

2026-08-09 * XCEL ENERGY
    liabilities:credit-cards:capitalone:venturex  -$80.00 ; date:2026-08-10
    expenses:home:utilities                        $80.00

On the first line, we have the transaction date, a * indicating that the transaction has posted, and a transaction description. The subsequent lines are the entries that constitute the transaction. Since this is double-entry accounting, the entries must always sum to zero and hledger checks this as it reads the journal. In this case, we are taking money out of the liability account for my VentureX credit card and applying it towards the utilities account. 第一行是交易日期,星号(*)表示交易已过账,后面是交易描述。随后的行是构成该交易的分录。由于这是复式记账,分录的总和必须始终为零,hledger 在读取日记账时会进行检查。在这个例子中,我们从 VentureX 信用卡的负债账户中扣除金额,并将其计入公用事业费用账户。

The hledger program parses the file, and allows you to generate useful reports such as showing a net worth breakdown via the balance command or a spending breakdown via the incomestatement command. Each of these commands can be scoped to a certain date range and/or show trends over time. hledger 程序会解析该文件,并允许你生成有用的报告,例如通过 balance 命令显示净资产明细,或通过 incomestatement 命令显示支出明细。这些命令中的每一个都可以限定在特定的日期范围内,和/或显示随时间变化的趋势。

That’s the essence of hledger. As I’ve converted to this system, I’ve discovered additional things that it helps with, some of which I didn’t even know I wanted it to do! Below, in no particular order, is a series of things which I like about the system. 这就是 hledger 的精髓。在转向这个系统后,我发现了它能提供的额外帮助,其中一些甚至是我之前没意识到自己需要的!以下是我喜欢该系统的几点功能(排名不分先后)。

Multi-Account Transactions

多账户交易

Transactions can have more than two accounts. This is particularly helpful for tracking transactions where multiple payment methods are used or where there is a mix of expense categories. The most common instance of this situation is Amazon transactions where I apply Prime rewards points or a gift card against the total. Here is an example transaction which demonstrates this: 交易可以涉及两个以上的账户。这对于追踪使用多种支付方式或混合了多种支出类别的交易特别有用。最常见的情况是亚马逊交易,我会在总额中抵扣 Prime 奖励积分或礼品卡。以下是一个演示此功能的交易示例:

2026-08-10 * Amazon
    expenses:home:decor              $37.99 ; Shoe Bench
    expenses:shopping:tech            $5.99 ; USB Cables
    expenses:taxes:sales              $2.20
    expenses:taxes:delivery-fee       $0.31
    assets:gift-cards:amazon        -$17.59
    income:rewards:amazon-prime      -$6.29
    liabilities:credit-cards:chase:amazon-prime -$22.61

In this transaction, I bought two items from Amazon, which applied to two different expense categories, and was charged sales tax and the Colorado Retail… 在这笔交易中,我从亚马逊购买了两件商品,它们分别属于两个不同的支出类别,并且被收取了销售税和科罗拉多州零售……