Schema Tax

Box 12 Code W on W2: HSA Contributions and Form 8889

By Schema TaxPublished Updated

Box 12 code W on a W2 shows the total that went into your health savings account (HSA) through your employer for the year. That total covers money your employer added and the pre-tax amounts you chose to put in through payroll. It is usually left out of Box 1, and the same figure goes on Form 8889, line 9.

What code W reports: employer and payroll HSA contributions

Code W is the Box 12 code for contributions to a health savings account that pass through an employer. The figure includes the employer's own deposits and the amounts an employee elected to put in through a cafeteria plan, the payroll arrangement that lets you pay for some benefits before tax. Both kinds of money sit in one number.

The IRS General Instructions for Forms W-2 and W-3 tell employers to "show any employer contributions (including amounts the employee elected to contribute using a section 125 (cafeteria) plan) to an HSA" with code W. The same instructions say employers "must report all employer contributions (including an employee's contributions through a cafeteria plan)" there. So if your pay stub shows an HSA deduction each pay period and your employer also adds a flat amount, the code W total should equal the two added together.

That answers the most common question about the code. Yes, code W includes what you put in through payroll. Many people expect code W to show only the employer's gift and are surprised by a larger number. A quick check is to add up the HSA line on your last pay stub of the year, which often shows a year-to-date total, and add any employer deposit listed in your benefits portal.

Code W does not include money you sent to the HSA yourself from a bank account. Those deposits never touched payroll, so they are not part of what your employer reports. Form 8889 asks for those deposits on a separate line, line 2, so no W-2 box records them.

As a fictional example, take an employee named Jordan Sample. Jordan's employer deposits $500 each January and July, for $1,000 in the year. Jordan also elects $100 per paycheck on a twice-monthly payroll, which adds up to $2,400. Jordan's W-2 shows W 3400.00 in one of the Box 12 slots. The two sources are not split out.

Why are code W amounts left out of Box 1?

Code W amounts are left out of Box 1 because HSA contributions through an employer are generally not taxable wages when they are expected to stay within the yearly limit. Box 1 shows wages subject to federal income tax. An HSA contribution that qualifies for the exclusion never enters that figure, so the W-2 lists it only in Box 12.

The W-2 instructions say an employer's contribution, including an employee's contributions through a cafeteria plan, is not subject to federal income tax withholding or Social Security and Medicare taxes "if it is reasonable to believe at the time of the payment that the contribution will be excludable from the employee's income." That is why the amount usually stays out of Box 1, Box 3 and Box 5 alike.

There is an exception. The same instructions say employer contributions that are not excludable "must also be reported in boxes 1, 3, and 5." An employer who knows a contribution will not qualify, for example because the worker has no qualifying health plan, adds it to wages. In that case code W still shows the contribution, and Box 1 includes it as well.

Your own HSA payments made outside a cafeteria plan are treated differently on the W-2. The instructions say an employee's contributions to an HSA, "unless made through a cafeteria plan," are includible in income as wages. That is the reason an after-tax payroll deduction to an HSA, if your employer offers one, does not appear under code W and stays inside Box 1. Form 8889 is where the IRS instructions treat those amounts, as a possible deduction.

A short way to hold this: pre-tax payroll money and employer money go under code W and stay out of Box 1. Money deposited on your own, or through after-tax payroll, stays in Box 1 wages, and Form 8889 handles it separately.

Carrying the code W amount to Form 8889

The code W amount goes on Form 8889, line 9, labelled "Employer contributions made to your HSAs." Form 8889 is the IRS form for health savings accounts that HSA holders attach to Form 1040. Line 9 reduces the room left for deductible contributions you made yourself, which you enter on line 2.

The IRS Instructions for Form 8889 say employer contributions on line 9 "should be shown on Form W-2, box 12, code W." The same instructions tell you not to include employer contributions on line 2, and say payroll contributions through a cafeteria plan "are treated as employer contributions and are not included on line 2." If you list your payroll HSA money on line 2 as well as line 9, you count it twice.

The line numbers below come from the 2025 Form 8889, and a later revision may renumber them. Part I of the form works like a short calculation:

LineWhat it holds
2HSA contributions you made yourself, not through an employer
3Your yearly limit, based on self-only or family coverage
6The limit after any Archer MSA contributions and spouse allocation
7The additional amount for people 55 or older, if it applies
8Line 6 plus line 7
9Employer contributions, the code W amount
11Line 9 plus line 10 (qualified HSA funding distributions)
12Line 8 minus line 11, or zero
13Your HSA deduction

The instructions say to "enter the smaller of line 2 or line 12 on line 13." In plain terms, your own deposits are deductible only up to the room code W leaves under the limit.

Tax software and spreadsheets both need the same code W figure. If you plan to move W-2 values into a return program, the guide to bringing form data into tax software covers how that handoff works and what to check after it.

How do direct HSA deposits combine with code W?

Direct HSA deposits combine with code W against one yearly limit. Money you send to the HSA from your own bank account goes on Form 8889, line 2. Code W goes on line 9. The form subtracts line 9 from your limit first, and only what is left can make line 2 deductible.

IRS Publication 969 gives the limits. For 2026, it says that with self-only coverage "you can contribute up to $4,400" and with family coverage "up to $8,750." The Form 8889 instructions add that someone 55 or older at the end of the year can make an additional contribution of $1,000, which goes on line 7.

A worked example with code W and a direct deposit

The numbers below are fictional. Jordan Sample from the earlier example is 41, had self-only coverage under a qualifying high-deductible health plan for all of 2026, and has no Archer MSA. Jordan's W-2 shows W 3400.00. In March 2027, Jordan also deposited $1,500 from a checking account and told the HSA trustee it was for 2026.

Form 8889 lineExample valueHow it is found
2$1,500Direct deposit for 2026
3$4,4002026 self-only limit from Publication 969
6$4,400No Archer MSA, no spouse split
7$0Under 55
8$4,400Line 6 plus line 7
9$3,400Code W from Box 12
11$3,400No funding distribution on line 10
12$1,000$4,400 minus $3,400
13$1,000Smaller of line 2 and line 12

Jordan put in $1,500 directly, but only $1,000 fits under the limit. The other $500 is an excess contribution. The next section explains what the Form 8889 instructions say about that.

If Jordan's direct deposit had been $800, line 13 would be $800 and $200 of room would remain. The form shows the remaining room only indirectly, as the gap between line 12 and line 2.

For people with more than one employer in the year, each W-2 shows only that employer's code W contributions. Line 9 asks for employer contributions in total, and the limit on line 3 applies to the person, not to each job.

Code W over the HSA limit: the excess contribution edge case

Code W can exceed your HSA limit when coverage changes partway through the year. The limit on Form 8889, line 3, shrinks for months without qualifying coverage, but payroll contributions often keep the original yearly pace. When code W alone is larger than line 8, the difference is an excess employer contribution.

The Form 8889 instructions figure line 3 month by month when your coverage changes. A worksheet has you enter the limit for each month you were an eligible individual on the first day of the month, add those amounts, and divide by 12. There is one shortcut. Under the last-month rule, the instructions say you may consider yourself an eligible individual for the entire year if you were eligible "on the 1st day of the last month of the tax year." Using that rule starts a testing period that "ends on the last day of the 12th month following that month," and losing coverage during it has its own consequences in Part III of the form.

An example where code W runs over

This example is fictional. Riley Example had self-only coverage from January through June 2026, then moved to a plan that does not qualify. Riley was not eligible on December 1, so the last-month rule does not apply. Six months at $4,400 each, divided by 12, gives a line 3 limit of $2,200. Riley's W-2 shows W 2600.00, because the employer front-loaded its deposit. Code W is $400 over line 8.

The instructions call this an excess employer contribution, the amount by which employer contributions exceed line 8. They say that if the excess "was not included in income on Form W-2, you must report it as 'Other income' on your tax return." They also allow you to withdraw the excess and have it treated as never contributed if you do so "by the due date, including extensions," of the return, and take out the earnings on it too.

If the excess stays in the account, the instructions point to a 6% tax: "Code section 4973 imposes a 6% tax on excess contributions to an HSA. See Code section 4973 and Form 5329." Whether to withdraw is a choice for you or your preparer. The W-2 itself does nothing different in this case. Code W simply shows what went in.

The same check applies to anyone who reads W-2s in bulk. A preparer with a client list can compare each code W amount with the limit for the coverage that client reports and flag any that run over. Schema Tax reads Box 12 into a separate code and amount for each slot, so a code W value arrives as its own field you can test against a limit; you can see how a W-2 box maps to its field in the interactive form demo.

Code W is one of many Box 12 codes, and retirement codes often sit beside it on the same form. Roth 401(k) contributions appear under a different code, explained in the post on what Box 12 code AA reports. School and nonprofit workers often see code E for 403(b) deferrals next to their code W. For where each other code goes on a return, see the guide to what to put for Box 12 on your taxes.

All posts in W-2 Box 12 and Box 14 Codes