Schema Tax

What a Tax Form Extraction API Returns

By Schema TaxPublished Updated

A tax form extraction API takes a PDF, scan or phone photo of a tax form and sends back JSON. Each value arrives with a fixed field name, the box number it came from, a typed value such as money or a date, and the checks it passed, so your code reads named fields, not page text.

What does a tax form extraction API accept as input?

A tax form extraction API accepts the files people already have: PDFs exported from a payroll portal, scanned paper forms, and photos taken with a phone. One upload can hold a single form or a PDF that mixes several forms, and the API sorts the pages before it reads any box.

Input files fall into three groups, and each one asks something different of the service.

A text PDF, such as a W-2 downloaded from a payroll site, already carries characters the software can read. The work there is matching each number to the right box, because the text layer alone does not say which figure is wages and which is withholding.

An image PDF or a scan holds only pixels. The service has to run optical character recognition first, and the result depends on resolution, contrast and how straight the page sits. The tax form OCR category covers how OCR and AI extraction read a page, from deskewing to label matching, so this post does not repeat it.

A phone photo adds shadows, perspective and curled paper. A good service straightens the image before reading and flags any box it cannot read with confidence instead of guessing.

The mixed PDF is the case that separates a form reader from a general OCR tool. A client packet might hold two W-2s, a 1099-INT and a 1098 in one file. Before extraction starts, each page has to be classified by form type and tax year, and pages that belong together, such as the parts of one multi-page statement, have to stay together. If the classification is wrong, every field after it is wrong too, so the response should report what the service decided for each page.

Most services also accept a few request options alongside the file: an ID you choose so you can match the result to your own record, and sometimes a hint about the expected form type. Treat a hint as a hint. The response should still tell you what the service found.

The fields inside a tax form extraction API response

A tax form extraction API response carries one record per form, and each record holds a fields object. Every field inside it pairs a fixed name with the box number it came from, a typed value, a status, and the checks the value passed. That pairing makes the data usable without a person reading the page again.

The example below is an illustrative response for one fictional W-2. Schema Tax has no public API documentation, so the URL https://api.example.com and every property name are placeholders that show the shape such a response can take. They are not a published Schema Tax format.

POST https://api.example.com/v1/extractions
Content-Type: multipart/form-data

file=harbor-lane-w2.pdf
client_reference=emp-0042
{
  "document_id": "doc_7f3a91",
  "client_reference": "emp-0042",
  "pages": 1,
  "forms": [
    {
      "form_type": "W-2",
      "tax_year": 2026,
      "page_range": [1, 1],
      "fields": {
        "employee_ssn": { "box": "a", "type": "tin", "value": "XXX-XX-1234", "status": "ok", "checks": ["ssn_pattern"] },
        "employer_ein": { "box": "b", "type": "tin", "value": "XX-XXX4521", "status": "ok", "checks": ["ein_pattern"] },
        "employer_name": { "box": "c", "type": "text", "value": "Harbor Lane Bakery Inc.", "status": "ok", "checks": [] },
        "wages": { "box": "1", "type": "money", "value": "52400.00", "status": "ok", "checks": [] },
        "federal_income_tax_withheld": { "box": "2", "type": "money", "value": "5980.00", "status": "ok", "checks": [] },
        "social_security_wages": { "box": "3", "type": "money", "value": "52400.00", "status": "ok", "checks": [] },
        "social_security_tax_withheld": { "box": "4", "type": "money", "value": "3248.80", "status": "ok", "checks": ["box4_is_6_2_percent_of_box3"] },
        "medicare_wages": { "box": "5", "type": "money", "value": "52400.00", "status": "ok", "checks": [] },
        "medicare_tax_withheld": { "box": "6", "type": "money", "value": "759.80", "status": "ok", "checks": ["box6_is_1_45_percent_of_box5"] },
        "allocated_tips": { "box": "8", "type": "money", "value": null, "status": "blank", "checks": [] },
        "control_number": { "box": "d", "type": "text", "value": "B7?41", "status": "needs_review", "checks": [] }
      }
    }
  ]
}

What each property means

PropertyExample valueWhat it tells your code
document_iddoc_7f3a91The service's ID for the upload, used to fetch it again
client_referenceemp-0042Your own ID, echoed back so you can match records
form_typeW-2What the classifier decided this page is
tax_year2026The year printed on the form
page_range[1, 1]Which pages of the upload this form came from
box"4"The box label as printed, kept as a string because boxes like a and 12b are not numbers
typemoneyHow to parse value: money, text, date, TIN, checkbox
value"3248.80"The typed value; money as a decimal string, never a float
statusok, blank, needs_reviewWhether to trust the value, skip it, or send it to a person
checks["box4_is_6_2_percent_of_box3"]The validations this value passed

The two rate checks in the example come from the form itself. The IRS General Instructions for Forms W-2 and W-3 show social security tax as 6.2% of the amount in Box 3 and Medicare tax as 1.45% of the amount in Box 5. In the sample, $52,400.00 times 6.2% is $3,248.80, and times 1.45% is $759.80, so both checks pass.

Money appears as a string on purpose. JSON numbers are often parsed as binary floating point, and the JSON specification, RFC 8259, notes that implementations approximate numbers within the precision they support. The post on decimal versus float for money in JSON explains the tradeoff in more depth.

How to name these fields, version them and validate them is a design question of its own. The guide to designing a tax form JSON schema covers envelope fields and naming rules, and the W2 extraction API field map lists a field for every W-2 box.

Tax data extraction API output compared with raw OCR text

A tax data extraction API returns named, typed values, while raw OCR returns the characters on the page in reading order. OCR output tells you that "52,400.00" appears somewhere near the top right. A typed field tells you that wages in Box 1 are 52400.00 and that the related checks passed.

Here is what plain OCR might return for the top of the same fictional W-2:

a Employee's social security number XXX-XX-1234
b Employer identification number (EIN) XX-XXX4521
1 Wages, tips, other compensation 2 Federal income tax withheld
52,400.00 5,980.00
3 Social security wages 4 Social security tax withheld
52,400.00 3,248.80

A developer who receives that text still has to do the hard part. Labels and values sit on different lines. Two values share one line, so the code has to know the column layout to decide which number belongs to Box 1 and which to Box 2. Commas and currency symbols need stripping. And the layout differs between the IRS version of the form and the substitute statements many employers and brokers print.

Fixed field names remove that work from your code. If wages is always the name for W-2 Box 1, your import logic does not change when a new payroll provider moves the box to a different spot on its printout. The name carries the meaning, and the box number stays alongside it so a reviewer can find the value on the page.

Typed values matter for the same reason. A date that arrives as a date, a checkbox that arrives as true or false, and an amount that arrives as a decimal string can go straight into a database column. Text from OCR has to be parsed and validated first, and every developer writes that parser slightly differently.

The checks are the third difference. OCR has no idea that Box 4 should be 6.2% of Box 3. An extraction service that knows the form can recompute totals and test rates, then tell you which values passed. A value that fails a check is a signal to look, not proof of an error, because a real form can carry an unusual amount.

Which forms can a tax document parsing API read?

A tax document parsing API reads the forms it has a schema for. Schema Tax reads the W-2, 1099-NEC, 1099-MISC, 1099-INT, 1099-DIV, 1099-B, 1098, 1040 and K-1. Each has its own set of named fields. Forms outside that list, such as the 1099-R, 1099-K, 1099-G, 1098-T and IRS transcripts, are out of scope.

The list matters because a form-aware service needs a schema per form. A W-2 has Box 12 code pairs and up to two state rows. A 1099-B can hold dozens of sales, each with its own dates, proceeds and basis. A K-1 carries coded line items. A service cannot return a fixed field name for a box it has no definition for, so a good tax document API says plainly which forms it covers.

Test what a service does with an unsupported form before you rely on it: the safe answer names the form it found and returns no fields, while forcing the page into the nearest schema produces right-looking names over wrong values. The guide on when a 1099 extraction API is the wrong tool walks through that test.

The supported list on the Schema Tax forms section shows what each form's fields cover, from W-2 Box 12 codes to every lot on a 1099-B.

Blank and unreadable boxes in a tax form extraction API response

Blank and unreadable boxes are two different states, and a tax form extraction API response should keep them apart. A blank box is empty on the form, so its value is null and its status says blank. An unreadable box has marks the service could not read with confidence, so it is flagged for review instead of guessed.

The difference changes what your code does next. In the example above, allocated_tips is blank. Many W-2s leave Box 8 empty, and treating that as zero in a total is usually fine. The control_number field is different: the service saw characters but could not settle on one of them, so it marked the value as needing review. Writing "B7?41" into a database as if it were final would hide the problem.

A few rules keep this clean:

  • Never return zero for a blank money box. Zero is a value someone typed on the form. Null means nothing was there.
  • Never drop a field from the record because it was blank. A missing key forces every client to guess whether the box was empty or the service skipped it.
  • Return a status on every field, even when it is "ok", so client code does not have to infer trust from the absence of a flag.

Confidence scores sit underneath the review status. Some services expose a number per field and let you pick your own cut-off. The post on setting a review threshold for confidence scores covers how to choose one and what it costs in review time.

Masked identifiers are a related case that is not an error. The IRS General Instructions for Forms W-2 and W-3 allow employers to truncate the employee's SSN on employee copies by replacing the first five digits with asterisks or Xs. A service that masks numbers before storage will also return XXX-XX-1234 even when the full number was printed. The post on masked SSNs in API responses describes the formats and how to match records on the last four digits.

Using structured data from tax forms in your own app

Structured data from tax forms is the start of a workflow, not the end. Once the response arrives, most apps do three things with it: store each form as its own record, send flagged fields to a person for review, and export the checked values to a spreadsheet, a ledger or another system.

Storing works best when you keep the whole record, not only the values you need today. Save the form type, tax year, page range and every field with its box number and status. A year from now, someone will ask where a number came from, and the box number and page range answer that without reopening the file.

Review is where the status field earns its place. Build a queue of fields whose status is "needs_review" and show each one next to the page image, so a person can confirm or correct it. Once a value is corrected, record who changed it and when. Schema Tax handles this step on an editable view of the form, so flagged values get fixed in place before anything is exported, and the same JSON comes back from the API, billed per page.

Export depends on who consumes the data. A preparer may want one spreadsheet row per form. An app may write each field into its own table. A data team may load the JSON as is and query it later. Because the field names are fixed, the mapping from response to destination is written once and reused for every form of that type.

A few habits prevent trouble later:

  • Key your own records on the client_reference you sent, not on file names, which change.
  • Check form_type and tax_year before mapping fields, so a 1099-INT never lands in a W-2 table.
  • Parse money strings with a decimal type in your language, not a float.
  • Keep the original file until review is done, then follow your own retention rules.

From here, the next step is picking field names that will survive future form revisions. The guide to designing a tax form JSON schema covers that in detail, and you can point at any box in the interactive form demo to see the field it maps to.

All posts in Tax Form APIs for Developers