Schema Tax

Tax Form to JSON: Typed Fields From a PDF or Scan

By Schema TaxPublished Updated

To convert a tax form to JSON, read each box into a field with a fixed name, a box label and a typed value, then wrap the fields in one document that records the form type and tax year. Store money so totals stay exact, put repeating boxes in arrays, and use null for a blank box rather than zero.

What tax form JSON should contain

Tax form JSON should contain one document per form, with metadata that says what the form is and a list of fields that say what each box held. Every field needs a box label, a stable name, a typed value and a record of its checks. With those, code can use the data without seeing the PDF.

Here is a fictional sample for one W-2. The employer, amounts and masked TINs are examples only.

{
  "form_type": "W-2",
  "tax_year": 2026,
  "source": { "file": "example-w2.pdf", "page": 1 },
  "employer": { "name": "Example Bakery Inc", "ein": "XX-XXX4821" },
  "employee": { "name": "Dana Example", "ssn": "XXX-XX-1234" },
  "fields": [
    { "box": "1", "name": "wages_tips_other_comp", "value": "48250.00", "checks_passed": [] },
    { "box": "2", "name": "federal_income_tax_withheld", "value": "5120.40", "checks_passed": [] },
    { "box": "3", "name": "social_security_wages", "value": "50250.00", "checks_passed": [] },
    { "box": "4", "name": "social_security_tax_withheld", "value": "3115.50", "checks_passed": ["box_4_is_6.2_percent_of_box_3"] },
    { "box": "12", "name": "box_12", "value": [
      { "slot": "a", "code": "D", "amount": "2000.00" }
    ], "checks_passed": [] },
    { "box": "14a", "name": "other", "value": null, "checks_passed": [] }
  ]
}

The top of the document answers "what is this?". form_type and tax_year let code route the form to the right handler. source points back to the file and page, which matters when one PDF holds several forms. The employer and employee blocks hold the identity fields, with the SSN already masked.

The fields array answers "what did it say?". Each entry keeps the printed box label next to a descriptive name, so a person checking the PDF and a program reading the data are talking about the same value. The checks_passed list records which validations held, such as Box 4 being 6.2% of Box 3, the employee rate given in the IRS Topic No. 751 on Social Security and Medicare withholding rates.

Box 14a in the sample is not a typo. The IRS General Instructions for Forms W-2 and W-3 for 2026 split Box 14 into 14a, "Other", and 14b, for Treasury tipped occupation codes. A schema that hard-codes last year's box list misses that change, which is one reason to version the schema along with the tax year.

In Schema Tax's JSON, every value keeps its box number, its field name and the checks it passed, and the API returns the same typed JSON as the download.

Tax form JSON keys: box numbers or field names?

Tax form JSON keys should be descriptive field names, with the box number kept as a separate value. A key like wages_tips_other_comp means the same thing on every W-2. A key like box_1 means wages on a W-2, rents on a 1099-MISC and interest on a 1099-INT, which breaks any code that handles more than one form type.

The IRS itself shows why. The IRS Instructions for Forms 1099-MISC and 1099-NEC label 1099-MISC Box 1 "Rents" and 1099-NEC Box 1a "Nonemployee Compensation". Box labels also change between years: the same instructions now list Boxes 1b, 1c and 1d on the 1099-NEC for cash tips, tipped occupation codes and overtime. A key tied to a box label has to change when the form does. A key tied to meaning does not.

Keep the box label anyway. People reading the JSON next to the PDF look for "Box 4", and a reviewer correcting a value needs to find it on the page. Storing "box": "4" beside "name": "social_security_tax_withheld" serves both readers.

Store box labels as strings, not numbers. Labels such as 1a, 12b and 14a are not numbers, and treating "1" as an integer while "1a" stays a string forces every consumer to handle two types for one field.

Pick one naming style and keep it: lowercase words joined by _ are common and easy to type. Avoid spaces, punctuation and abbreviations that only make sense to the person who wrote the schema. A key should still be readable a year later by someone who has never seen the form.

How should tax form JSON store money amounts?

Tax form JSON should store money amounts in a form that cannot drift when added up: either a decimal string such as "5120.40" or an integer count of cents such as 512040. A plain JSON number with a fraction is easy to write but leaves the exact value up to whichever parser reads it.

The reason is in the JSON standard, RFC 8259. It says good interoperability comes from implementations that expect no more precision or range than IEEE 754 double precision provides, and that integers from -(2^53)+1 through (2^53)-1 will agree exactly across implementations. It promises nothing equally firm about decimal fractions. Integer cents stay inside that promise for any amount a tax form will ever hold.

Decimal strings have a different strength: they read exactly as printed on the form. The IRS General Instructions for Forms W-2 and W-3 ask for amounts without a dollar sign or comma but with the decimal point, in the format 00000.00, and with cents shown even when they are .00. A string like "48250.00" follows that format, so comparing JSON to the PDF is a matter of reading the same characters.

Whichever you choose, be consistent and say so in the schema. A worked example shows what mixing costs. A fictional consumer adds three 1099-INT interest amounts, "412.10" as a string, 388.25 as a number and 9965 as cents. Code that assumes one type either throws an error or returns a total off by a factor of 100. With every amount stored as a decimal string and summed with a decimal library, the total is "1764.00", which a person can check against the three forms by hand.

Never store formatted text such as "$5,120.40". The dollar sign and comma are display choices, and every consumer then needs code to strip them.

Repeating tax form sections as JSON arrays

Repeating tax form sections belong in JSON arrays: one array per repeating box, one object per entry. Box 12 codes on a W-2, state lines on a W-2 or 1099, sales on a 1099-B and coded lines on a K-1 all repeat, and an array holds as many entries as the form has.

The W-2 sets clear limits. The IRS General Instructions for Forms W-2 and W-3 say Copy A of a W-2 holds up to four Box 12 entries, with a second W-2 for more, and that boxes 15 through 20 cover two states and two localities. In JSON, box_12 is an array of objects with slot, code and amount, and state is an array of objects with the state, the employer's state ID, state wages and state tax. Two entries or four, the shape is the same.

Each object keeps its parts together. A Box 12 entry stores the code letter and its amount in one object, so sorting or filtering the array never separates them. The IRS General Instructions for Forms W-2 and W-3 give the example of $5,300.00 in 401(k) deferrals entered as code D followed by the amount; in JSON that is { "code": "D", "amount": "5300.00" }.

Brokerage statements are the largest case. The IRS Instructions for Form 1099-B say brokers generally report each transaction separately, with the description in Box 1a, dates acquired and sold in Boxes 1b and 1c, proceeds in Box 1d and cost basis in Box 1e. A JSON 1099-B can hold the broker once and an array of sales, each with those five fields plus any wash sale amount from Box 1g.

Keep arrays even when they hold one entry or none. A state field that is an object on one form and an array on another forces every consumer to check which it got. An empty array says "this form had no state lines" without any special case.

For a side-by-side view of how arrays compare with flat rows, see which format keeps tax form structure intact, JSON or CSV.

Is tax form JSON useful without writing code?

Tax form JSON is useful without writing code, because it is plain text that a person can read and Excel can import. You need code to build an app on it, not to look at it, check it or turn it into a sheet. The skill is knowing where the values sit.

Excel's import is the most practical route. Microsoft's guide to importing data from data sources with Power Query lists the path Data, Get Data, From File, From JSON, then choosing the file. Because the sample keeps every box in one fields array, each entry maps naturally to one row with the same columns: box, name and value, much like a long CSV.

The other way round also works: keep JSON as the master copy and produce CSV or Excel from it when a person needs a sheet. That way the typed values and nested lists exist somewhere, even if the spreadsheet flattens them.

Reading a JSON file by eye takes a minute of practice. Curly braces hold one record, square brackets hold a list, and each "key": value pair is one field. In the sample at the top of this post, find "fields", then scan each entry's box and value.

A non-developer who exports JSON today also has data a developer can use tomorrow without extracting the forms again. The tax form API category covers full schemas and responses for that work.

Source files matter too. A fillable PDF can sometimes give up its field values directly, before anything is flattened; the post on extracting form fields from a PDF before it is flattened covers that route. For paper, the guide to a scanned tax form to Excel and the one on a tax form photo to Excel cover getting a clean image first.

Null versus zero for empty boxes in tax form JSON

Empty boxes in tax form JSON should be null, not zero. Null means the box was blank on the form. Zero means the issuer printed 0.00. Code that treats the two alike will report blank boxes as reported amounts, and totals, averages and checks will quietly include values that were never on the form.

The JSON standard, RFC 8259 defines null as its own literal, separate from numbers and strings, so JSON can make this distinction where CSV cannot. Use it.

The difference changes results. Take a fictional 1099-NEC with Box 1a at "7400.00" and Box 4 left blank, and a second with Box 4 printed as "0.00". Both mean no tax was withheld, but only the second form said so. A count of "forms that reported withholding" should include the second and not the first. Convert the blank to zero and both count.

Checks suffer most. A rule such as "state income does not exceed Box 1a" passes trivially when a blank state box becomes 0, and a rate check on a blank Box 4 fails for no real reason. Keeping null lets a check say "not applicable" instead of producing a false pass or fail.

Keep the key even when the value is null. A missing key could mean the box was blank, or that the extractor never looked. An explicit "value": null says the box was read and was empty.

Arrays follow the same idea. An empty box_12 array means the form had no codes; a missing box_12 field is ambiguous. On Schema Tax, a box the model was unsure about is flagged for a person to confirm rather than filled with a guess, and the interactive demo shows where each box lands in the output.

All posts in Tax Forms to Excel, CSV and JSON