Formalizing Hong Kong salaries tax把香港薪俸稅寫成程式
We rewrote Hong Kong salaries tax as code, matched all figures that the Inland Revenue Department publishes in its own worked examples and tables, then searched 5,000 households for the choices that cut their tax. Pay never loses money as it rises, the IRD's own rule of thumb for claiming children costs some couples tens of thousands of dollars, and nothing we found is the size of the big long-term tax moves. Hong Kong's real money is in how income is structured, not in one year of the salaries tax.
我們把香港薪俸稅寫成程式,與稅務局在例子和表格中公布的全部 個數字逐一核對,分毫不差;然後模擬 5,000 個家庭,找出能減少稅款的選擇。結果是:加薪永遠不會令稅後收入減少;稅務局自己的「由誰申索子女免稅額」指引,會令部分夫婦多交數以萬元計的稅;而我們找到的漏洞,沒有一個大到像美國那種長線大型節稅方法。香港真正的大錢,在於收入如何安排,而不在一年的薪俸稅之內。
Largest example of each finding, HK$ of tax a year, from the model below. Red marks the findings we have not seen written up. Each is explained in sections 4 and 5.每項發現的最大例子,以每年港元稅款計,數字來自下文模型。紅色為我們未見有人寫過的發現,詳見第 4 及第 5 節。
Pointing a calculator at the Inland Revenue Ordinance用計算程式檢驗《稅務條例》
A recent post formalized the US income tax in the Lean proof checker and searched it for loopholes.1 That post found that one year of the US code holds no big loopholes, and that the large gains come from moves over many years. We wanted to know whether the same holds for Hong Kong, and how far a much simpler model gets.
Hong Kong is a good test. The Inland Revenue Ordinance (Cap. 112) is short, salaries tax is one formula with a list of allowances, and there is no tax on capital gains, dividends or estates. So this first pass is deliberately simple: salaries tax for one household and a few neighbouring rules, written in about 300 lines of plain Python, not Lean. The checks below run every income on a grid; they are tests, not proofs.
最近有一篇文章用 Lean 證明檢查器把美國入息稅寫成程式,再從中搜尋漏洞。1 該文發現,美國一年的稅法並無大漏洞,大筆節稅來自跨越多年的安排。我們想知道香港是否一樣,以及一個簡單得多的模型能走多遠。
香港是很好的測試對象。《稅務條例》(第 112 章)篇幅短,薪俸稅只是一條公式加一列免稅額,而且不徵資本增值稅、股息稅或遺產稅。因此這次刻意從簡:只處理一個家庭的薪俸稅及幾條相關規則,用約 300 行 Python 寫成,而非 Lean。下文的檢查會在一個網格上逐一計算每個收入;它們是測試,不是數學證明。
1. Rewriting salaries tax as code that can be checked1. 把薪俸稅改寫成可檢驗的程式
The core is section 13 of the ordinance: tax at progressive rates on net chargeable income, capped at the standard rate on net income before allowances. Since 2024/25 the standard rate has two tiers, 15% on the first $5 million and 16% above.2
核心是條例第 13 條:應課稅入息實額按累進稅率計稅,但上限為以標準稅率計算的入息淨額(未扣免稅額)稅款。自 2024/25 年度起,標準稅率分兩級:首 500 萬元 15%,其餘 16%。2
def tax_before_reduction(net_income, allowances):
# s13: the lower of the two / 第 13 條:取兩者中較低者
return min(progressive(net_income - allowances), standard(net_income))
Around that sit the allowances and deduction ceilings, one parameter set per year, taken from the IRD's rate table (PAM 61(e), August 2026).2 The 2026/27 Budget raised most allowances by about 10%:
外圍是各項免稅額和扣除上限,每個年度一組參數,取自稅務局的稅率表(PAM 61(e),2026 年 8 月)。2 2026/27 年度《財政預算案》把大部分免稅額提高約 10%:
| Allowance免稅額 | 2025/26 | 2026/27 |
|---|
The model also covers the married-couple choices (separate taxation, joint assessment, which spouse claims each allowance), the 10% "rental value" of employer-provided housing, the 60-day rule for employments based outside Hong Kong, property tax against personal assessment for a landlord, and profits tax for an owner-managed company. No one-off tax reduction has been announced for 2026/27, so none is applied.
模型亦涵蓋已婚夫婦的選擇(分開評稅、合併評稅、由哪一方申索各項免稅額)、僱主提供居所的 10%「租值」、非香港受僱的 60 日規則、業主的物業稅與個人入息課稅比較,以及東主公司的利得稅。2026/27 年度尚未公布一次性寬減稅款,故沒有計入。
2. It matches all of the IRD's own figures2. 與稅務局公布的數字全部吻合
The IRD publishes worked examples: five in its Brief Guide to Taxes, two in its leaflet on joint assessment, and a table of the income at which each household type reaches the standard rate.345 At each income in that table, progressive tax and standard-rate tax must be equal, which tests the allowances and both rate schedules together. Every figure matched to the dollar.
稅務局公布了多個計算例子:《稅務簡介》中的五個、合併評稅單張中的兩個,以及一張列出各類家庭在多少收入時開始按標準稅率計稅的表。345 在該表的每個收入水平,累進稅款必須剛好等於標準稅率稅款,這同時檢驗了免稅額和兩套稅率。所有數字均準確至元。
| Source來源 | Case個案 | IRD稅務局 | Model模型 |
|---|
3. Pay never loses money as it rises3. 加薪永遠不會令稅後收入減少
We ran every salary from $0 to $20 million in $1,000 steps for six household types, computations in all. Three properties held at every point: tax never exceeds the standard rate on net income; the marginal rate never exceeds ; and take-home pay never falls when pay rises. There are no cliffs in income, unlike the US, where one dollar of investment income can cost a family $8,046 of earned income credit.1
我們以每 1,000 元為一級,計算由 0 至 2,000 萬元的每個薪金,涵蓋六類家庭,合共 次計算。每一點都符合三項性質:稅款從不超過標準稅率稅款;邊際稅率從不超過 ;加薪後稅後收入從不減少。香港薪俸稅沒有收入「懸崖」,不像美國:一個家庭多一元投資收入,可損失 8,046 美元的勞動所得抵免。1
The curve does show one oddity. A single person earning between about $350,000 and $2.13 million pays 17% on each extra dollar. Above that, the standard rate takes over and the marginal rate falls to 15%, then rises to 16% after $5 million of net income. Middle earners face a higher marginal rate than millionaires.
不過曲線顯示一個怪現象:單身人士年收入約 35 萬至 213 萬元之間,每多賺一元要交 17%;再高就改按標準稅率,邊際稅率跌至 15%,入息淨額超過 500 萬元後才升至 16%。中等收入人士的邊際稅率,竟高於百萬富翁。
Marginal rate on the next dollar, single person, 2026/27, no deductions.多賺一元的邊際稅率,單身人士,2026/27 年度,未計扣除。
4. A search found the moves tax advisers already use4. 搜尋重新找到稅務顧問已在用的方法
For each household the search tries every lawful choice and keeps the cheapest. These are the moves it found that are already documented by the IRD or in common practice. They are legal elections and allowed arrangements, but each has conditions, and the IRD can challenge arrangements made mainly to avoid tax (sections 61 and 61A).
搜尋程式為每個家庭嘗試所有合法選擇,保留稅款最低者。以下是它找到、稅務局文件或業界早已記載的方法。它們都是合法的選擇或安排,但各有條件;若安排主要為避稅而作,稅務局可引用第 61 及 61A 條提出質疑。
5. Odd corners we found5. 我們找到的冷門角落
These are the findings we have not seen written up. No tax adviser has reviewed them yet, so treat them as questions to check, not advice.
以下是我們未見有人寫過的發現。尚未經稅務顧問審閱,請視之為有待查證的問題,而非稅務意見。
6. Why one year of Hong Kong salaries tax holds nothing Roth-sized6. 為何一年的香港薪俸稅沒有「Roth 級」大漏洞
The US backdoor Roth is big because two rules combine to remove an income limit, and the money then compounds tax-free for decades. Nothing in one year of Hong Kong salaries tax works like that. The rates top out at 17%, no allowance phases out with income, and every choice we found is worth a few thousand dollars a year for most households, and under $200,000 even for an owner whose company earns $30 million.
Hong Kong's large gains are already in the design of the system. There is no tax on capital gains, dividends or inheritance, so the move that matters is where and in what form income arises, not how a salary is taxed. The owner-manager example shows the shape: a company keeps its first $2 million of profit at 8.25%, pays the rest as salary taxed at 15 to 16%, and pays out what is left as untaxed dividends. Bigger questions sit in parts of the law this model does not touch:
- Source. Hong Kong taxes only profits that arise in Hong Kong. Whether profit is offshore is decided case by case under court rulings, not by a formula.
- Capital or revenue. A gain on selling property or shares is untaxed if it is capital and taxed if it comes from trading. Again a judgement, now partly settled by a safe harbour for some share disposals.
- Funds, family offices and foreign income. The fund exemption, the family-office concession and the foreign-sourced income exemption rules each turn on tests of substance and control.
- Global minimum tax. Large groups now pay at least 15% under the 2025 rules, which closes much of the gap for them.
Our guess, as in the US post, is that anything Roth-sized and unpublished lies in those structures. That is a guess, not a finding; a model of them would need to treat the judgements as inputs.
美國的「後門 Roth」之所以巨大,是因為兩條規則結合後取消了收入上限,資金其後可免稅複利滾存數十年。一年的香港薪俸稅中沒有這樣的機制:最高稅率只是 17%,沒有免稅額會隨收入遞減,我們找到的每項選擇,對大部分家庭每年只值數千元;即使公司年賺 3,000 萬元的東主,也不足 20 萬元。
香港的大筆節稅,早已寫在制度設計之中。香港不徵資本增值稅、股息稅或遺產稅,所以關鍵在於收入在哪裏、以甚麼形式產生,而不是薪金如何計稅。東主公司的例子正好說明:公司首 200 萬元利潤按 8.25% 課稅,其餘以薪金發放、按 15% 至 16% 課稅,餘下的以免稅股息派發。更大的問題,在於本模型未有觸及的法律範疇:
- 利潤來源。香港只對源自香港的利潤徵稅。利潤是否屬離岸,須按法院判例逐案決定,沒有公式可循。
- 資本性質或營業性質。出售物業或股票的收益,屬資本性質則不課稅,屬買賣營業則要課稅。這同樣靠判斷,現時部分股份出售已有「安全港」規則。
- 基金、家族辦公室及外地收入。基金豁免、家族辦公室稅務寬減及外地收入豁免機制,均取決於經濟實質和控制權等測試。
- 全球最低稅。根據 2025 年的規則,大型跨國集團現須最少繳付 15%,大大收窄了它們的空間。
我們與美國那篇文章一樣推測:若真有尚未公開的「Roth 級」漏洞,應藏於上述架構之中。這只是推測,不是發現;要為這些範疇建模,必須把相關判斷當作輸入條件。
7. What it would take to do the whole ordinance7. 把整部條例寫成程式需要甚麼
The steps from here are clear, and Hong Kong makes the first one easy. Hong Kong e-Legislation publishes Cap. 112 as structured XML with past versions, so the ordinance can be stored in git with one commit per amending ordinance.6 Then:
- Cross-reference checks: every "section 8(1B)" or "subsection (2)" must point to a provision that exists and is in force on that date.
- English and Chinese texts side by side. Both are equally authentic. A check that the two versions cite the same sections and carry the same numbers is something the US has no equivalent of.
- Proofs instead of a grid: move the model to Lean and prove the properties in section 3 for every income, not just every $1,000.
- Profits tax and property tax in full, then personal assessment across all three.
下一步很清楚,而香港令第一步特別容易。電子版香港法例以結構化 XML 發布第 112 章及其過往版本,因此可以把條例存入 git,每條修訂條例一個 commit。6 然後:
- 交叉參照檢查:每個「第 8(1B) 條」或「第 (2) 款」都必須指向在該日期存在並生效的條文。
- 中英文本對照。兩種文本同等真確。檢查兩個版本引用相同條文、數字一致,是美國沒有的工作。
- 以證明取代網格:把模型移植到 Lean,證明第 3 節的性質對每一個收入都成立,而不只是每 1,000 元。
- 完整的利得稅及物業稅,然後是涵蓋三者的個人入息課稅。
Limits局限
- Coverage. Salaries tax for one household in one year. Simplified versions of property tax, personal assessment and profits tax. No share options, holiday-journey benefits, lump sums, or apportionment for part-year employment.
- Who checked it. The code was tested against the IRD's own examples; no tax adviser has reviewed it or the findings.
- Open question. IRD material does not say whether a jointly assessed couple's 15% tier is $5 million or $10 million. The model uses $5 million for the couple; it changes few results.
- Not advice. Each finding depends on facts the model reduces to yes or no.
- 涵蓋範圍。只計一個家庭一年的薪俸稅,物業稅、個人入息課稅及利得稅均為簡化版本。未計股份認購權、度假旅程利益、一筆過款項,亦未處理年中受僱的分攤。
- 由誰核對。程式已用稅務局的例子測試,但程式及各項發現均未經稅務顧問審閱。
- 未解問題。稅務局資料沒有說明合併評稅夫婦的 15% 一級是 500 萬元還是 1,000 萬元。模型以夫婦合共 500 萬元計算,對結果影響不大。
- 並非稅務意見。每項發現都取決於實際情況,模型只把它們簡化為「是」或「否」。
The code (model, tests and search) is published alongside this page:程式碼(模型、測試及搜尋)與本頁一同發布: model.py, tests.py, search.py.
References參考資料
- Formalizing the US tax code, the post that inspired this one.,啟發本文的文章。
- Inland Revenue Department,稅務局, Allowances, Deductions and Tax Rate Table, PAM 61(e), August 2026.,2026 年 8 月。
- Inland Revenue Department,稅務局, A Brief Guide to Taxes Administered by the IRD, examples A to E.,例子 A 至 E。
- Inland Revenue Department,稅務局, Joint Assessment & Personal Assessment for Married Couples.
- GovHK Tax Rates of Salaries Tax & Personal Assessment; Allowances.
- Hong Kong e-Legislation,電子版香港法例, Inland Revenue Ordinance (Cap. 112).
- Board of Review decision稅務上訴委員會決定 D37/01, on counting days under the 60-day rule.,關於 60 日規則如何計算日數。