Schema CPA

W2 OCR: Pull Every Box From a W-2 Into a Spreadsheet

By Schema CPAPublished Updated

W2 OCR pulls every box from a W-2 PDF, scan or photo into one spreadsheet row per form: employer and employee details, Boxes 1 to 11, each Box 12 code with its amount, Box 13 checkboxes, Boxes 14a and 14b, and up to two state and local lines. Check the totals before anyone keys a single figure.

W-2 boxes W2 OCR must capture

W2 OCR must capture every lettered and numbered box on the form, because a preparer cannot tell from a spreadsheet which empty cell was blank on the page and which was missed. The IRS General Instructions for Forms W-2 and W-3 (2026) define the boxes, and the 2026 form changed some of them.

Identity boxes

Boxes a to f identify the people involved. Box a is the employee's social security number, Box b the employer identification number (EIN), Box c the employer's name, address and ZIP code, Box d the control number, and Boxes e and f the employee's name and address. The EIN ties a W-2 to an employer from year to year, so it is the most useful field for matching.

Wage and tax boxes

Boxes 1 to 11 carry the money. Box 1 is wages, tips and other compensation; Box 2 is federal income tax withheld; Boxes 3 and 4 are social security wages and tax; Boxes 5 and 6 are Medicare wages, tips and tax; Box 7 is social security tips; Box 8 is allocated tips; Box 10 is dependent care benefits; and Box 11 is nonqualified plans. The 2026 instructions say Box 9 was reduced in size to make room in Box 14a.

Box 12, Box 13 and Box 14

Box 12 holds code and amount pairs, covered in its own section below. Box 13 has three checkboxes: statutory employee, retirement plan and third-party sick pay. For 2026, Box 14 is split. The instructions say information previously reported in Box 14 now goes in Box 14a, labelled Other, and the new Box 14b holds Treasury Tipped Occupation Codes, up to two, when cash tips are reported in Box 12 with code TP.

State and local boxes

Boxes 15 to 20 hold state and local information: the state and the employer's state ID, state wages, state income tax, local wages, local income tax and the locality name. The W-2 instructions say these boxes can report two states and two localities, and that an employer prepares a second W-2 for more than two.

Extracting data from a W-2 PDF versus a scanned W-2

To extract data from a W-2 PDF, first check whether the file has a text layer. A PDF downloaded from a payroll portal often contains the actual characters, which software can copy exactly. A scanned or photographed W-2 is only an image, so OCR has to recognize every digit, and errors become possible.

Text-layer PDFs

A quick test tells the two apart. Open the PDF and try to select the Box 1 amount with the cursor. If the digits highlight one by one and paste correctly into a blank document, the file has a text layer. Values from a text layer are as reliable as the payroll system that produced them.

The hard part with a text-layer PDF is position, not reading. The characters are exact, but the software still has to know which number belongs to which box. A payroll provider's substitute layout can put boxes in a different order from the IRS form, so the reader must map each value to its box by label, not by where it sits on the page.

Scans and photos

A scanned W-2, or a phone photo of a paper copy, has no characters at all until OCR produces them. Quality matters here: a crooked photo, a shadow over Box 12, or a faint photocopy all lead to misreads. Expect to review more fields from images than from text-layer PDFs.

One habit helps either way. Ask clients for the PDF from the payroll portal whenever the employer offers one, rather than a photo of the printed copy. The same W-2 then arrives as exact text instead of an image.

What columns belong in a W-2 to Excel sheet?

A W-2 to Excel sheet needs one row per W-2, with a column for every box, a separate column for each Box 12 code and its amount, two sets of state and local columns, and a source column naming the file and page. Extra state lines beyond two come from a second W-2, so they get their own row.

Column template with a sample row

The template below lists each column down the page with one fictional sample value. In the spreadsheet, each item is a column and each W-2 is a row. The employee, employer, numbers and IDs are made up for the example.

ColumnSample value
ClientRivera household
Tax year2026
Source file and pageRivera_W2_Example-Freight.pdf p.1
Box a employee SSNXXX-XX-4821
Box b employer EIN04-XXX7310
Box c employer nameExample Freight Lines Inc
Box e employee nameMarisol Rivera
Box 1 wages, tips, other comp.71,250.00
Box 2 federal income tax withheld8,040.00
Box 3 social security wages76,000.00
Box 4 social security tax withheld4,712.00
Box 5 Medicare wages and tips76,000.00
Box 6 Medicare tax withheld1,102.00
Box 12 code 1 / amount 1D / 4,750.00
Box 12 code 2 / amount 2DD / 9,860.00
Box 12 code 3 / amount 3(blank)
Box 12 code 4 / amount 4(blank)
Box 13 retirement planYes
Box 14a other(blank)
Box 14b tipped occupation code(blank)
State 1 / employer state IDNY / XXXX-4821
State 1 wages / tax52,400.00 / 2,610.00
State 2 / employer state IDNJ / XXXX-4822
State 2 wages / tax18,850.00 / 790.00
Corrected (W-2c)No
Duplicate of(blank)

The sample checks out: Box 4 is 6.2% of Box 3 (76,000.00 x 0.062 = 4,712.00) and Box 6 is 1.45% of Box 5 (76,000.00 x 0.0145 = 1,102.00). The arithmetic and other checks that apply to any form are explained in checks that catch tax document OCR errors.

Formatting the columns

Format identity columns as text before pasting data in. Microsoft's Excel support page on keeping leading zeros says Excel automatically removes leading zeros and that formatting cells as Text does not change numbers already entered. An EIN that starts with 0, like the example above, loses its first digit if the column is left as a number. When importing a CSV, the same page shows how to set a column's data type to Text in Power Query.

Keep amounts as numbers with two decimals, so totals and checks work. Keep the code columns as text, so a code like "D" never gets read as anything else.

Where the file goes

Name the export by client and year, and store it in the client's folder next to the source PDFs. Folder and naming conventions are covered in the organizing client files category. Schema CPA reads W-2s and exports the result as Excel or CSV for the firm to work from; the workflow on the homepage shows the path from upload to export.

What do Box 12 codes look like after W2 OCR?

After W2 OCR, Box 12 should come out as separate pairs: a code of one or two capital letters and an amount, each in its own column. The W-2 instructions put the code left of a vertical line and the amount right of it, and allow no more than four items on Copy A.

Splitting the pairs

The risk is merging. A reader that misses the vertical line can return "D4750.00" as one string, or attach the amount from the second line to the first code. Each pair should land in a code column and an amount column, numbered 1 to 4 in the order printed.

Catching misread letters

Code letters are short, so a single misread changes the meaning. The W-2 instructions list codes from A to Z (skipping some letters), double-letter codes AA to II, and three new codes for 2026: TA for employer contributions under a section 128 Trump account contribution program, TP for the total amount of cash tips reported to the employer, and TT for the total amount of qualified overtime compensation.

That list gives a simple check. Any code not on it is a misread. The letters I, O and U are not single-letter codes, so an "O" read where a "D" was printed fails the check. A code that is valid but unusual for the client, such as a first-ever code W employer HSA contribution, is worth a glance against the page.

Some codes connect to other boxes. Code TP cash tips relate to Box 14b, which the instructions say holds the Treasury Tipped Occupation Code when code TP is used. A W-2 with code TP and an empty Box 14b, or the reverse, deserves a look at the page.

W2 OCR edge cases: W-2c forms, multiple states and duplicate copies

The W2 OCR edge cases that cause the most trouble are corrected forms, employees with more than two states, and the same W-2 arriving more than once. Each can add or remove wages from the sheet without any single box looking wrong, so the sheet needs columns and rules that handle them.

W-2c forms

The IRS describes Form W-2c as Corrected Wage and Tax Statements, used to fix errors on a W-2 already filed and to give employees corrected copies. A W-2c is not a second W-2. Give it its own row, mark the Corrected column, and link it to the original row so the preparer sees both sets of figures. The W-2 instructions also note that a W-2c filed only to correct social security and Medicare items for a prior-year repayment does not correct Box 1 or Box 2.

More than two states

An employee who worked in three states may receive two W-2s from the same employer, because the form holds only two state lines. Both forms carry the same EIN. Give each its own row, and flag the pair so the preparer confirms how the amounts on the two forms relate before any total is taken.

Duplicate copies

The W-2 instructions say employers furnish Copies B, C and 2 to the employee. A client may scan all three, or send the portal PDF and a photo of the paper copy. Each is the same W-2. Match on employer EIN, employee SSN and Box 1, keep the first as the source, and fill the "Duplicate of" column on the others instead of deleting them.

Other forms in the same pile

W-2s rarely arrive alone. The same approach, one row per form with a column for each box, extends to the 1099 series; see 1099 OCR for interest, dividend and miscellaneous forms, and 1099-B data entry for brokerage transactions, where one form can hold many rows.

All posts in Tax forms, W-9s and payroll paper