Skip to content

Instantly share code, notes, and snippets.

@divergentdave
Last active April 24, 2016 17:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save divergentdave/91abeb6de958c158ae3a73ef03f19361 to your computer and use it in GitHub Desktop.
Save divergentdave/91abeb6de958c158ae3a73ef03f19361 to your computer and use it in GitHub Desktop.
Export from Free File Fillable Forms to 1040.js
# It would be a bad idea to share HAR or JSON files containing your documents
*.har
*.json

Free File Fillable Forms to 1040.js exporter

Disclaimers

I wrote this script for my own edification and entertainment. Don't rely on this to be accurate or correct. Many tax situations won't be properly supported.

Don't share any .har files, .json files, screenshots, or PDFs from Free File Fillable Forms unless you know what you are doing and have thoroughly sanitized private information. Your tax documents contain not only your social security number, bank account number, and E-file PIN, but also your AGI, plus everything used to calculate it, which may be used to authenticate your next year's tax return filing. Guard all related captures, documents, and data files with care, as you would your tax documents themselves.

Overview

This script will export fields from Free File Fillable Forms tax documents and output a snippet to enter the same values into 1040.js. To run the script, you will need to install the Node.js runtime.

The script takes input in the form of HTTP Archive files from your browser. To capture your tax forms, log into Free File Fillable Forms, open your browser's network monitor, click through each of your forms in the web app, then right click in the network monitor pane and select "Save as HAR with Content" (Chrome) or "Save All As HAR" (Firefox 41 and newer). Save this HAR file into the same directory as this script. Then, open up a command prompt and run node readhar.js. The script will read that file and output a (long) snippet of JavaScript to be run in your browser. Copy the whole output, open up 1040.js, and paste the snippet into your browser's console. The snippet will update the avocado-colored nodes, and then recalculate all values.

var fs = require("fs");
var util = require("util");
var GET_URL = "https://www.freefilefillableforms.com/quadf/service/taxreturn/form/get";
var forms = {
F1040: {},
F8582W15: {},
FSCHA: {},
FSCHE1: {}
};
var filenames = fs.readdirSync(".");
for (var i = 0; i < filenames.length; i++) {
var filename = filenames[i];
if (!filename.endsWith(".har")) {
continue;
}
var stat = fs.statSync(filename);
if (!stat.isFile()) {
continue;
}
var har = JSON.parse(fs.readFileSync(filename));
for (var j = 0; j < har.log.entries.length; j++) {
var entry = har.log.entries[j];
if (entry.request.url != GET_URL) {
continue;
}
var post_json = JSON.parse(entry.request.postData.text);
if (post_json.taxYear != "2015" || post_json.agency != "fd") {
continue;
}
var form_id = null;
for (var k = 0; k < post_json.agencies.length; k++) {
var agency = post_json.agencies[k];
if (agency.id == "S2015FDD" || agency.id == "S2015USFDD") {
for (var l = 0; l < agency.forms.length; l++) {
var form_id = agency.forms[l].id;
}
}
}
var response_json = JSON.parse(entry.response.content.text);
forms[form_id] = response_json.value.agencies[0].forms[0].fields;
}
}
/*
* To get a list of input cells, open b-k.github.io/1040.js, set the checkboxes
* as desired, and run the following snippet in the developer console.
*
* svg.selectAll(".u").each(function(i) {
* console.log(g._nodes[i].form + "_" + g._nodes[i].baselabel);
* });
*/
/*
* The FFFF documents are available at the following URLs.
*
* https://www.freefilefillableforms.com/data/fd/form/F1040.json
* https://www.freefilefillableforms.com/data/fd/form/FSCHA.json
* https://www.freefilefillableforms.com/data/fd/form/FSCHE1.json
* https://www.freefilefillableforms.com/data/fd/form/F8582W15.json
*
* Each entry field has an identifier, stored in the property "Id". All entered
* values are stored in the `get` JSON documents under "fields", with names
* equal to these identifiers.
*/
var avocados = {
// Note: Several FFFF input IDs don't match the line numbers on the form.
// Such line numbers were probably taken from previous years' forms.
f1040_wages: forms.F1040.L7 || 0,
f1040_interest: forms.F1040.L8A || 0,
f1040_dividends: forms.F1040.L9 || 0,
f1040_taxable_tax_refunds: forms.F1040.L10 || 0,
f1040_alimony: forms.F1040.L11 || 0,
f1040_sched_c: forms.F1040.L12 || 0,
f1040_cap_gains: forms.F1040.L13 || 0,
f1040_taxable_ira_income: forms.F1040.L15B || 0,
f1040_taxable_pension: forms.F1040.L16B || 0,
f1040_farm_income: forms.F1040.L18 || 0,
f1040_unemployment: forms.F1040.L19 || 0,
f1040_taxable_ss_benefits: forms.F1040.L20B || 0,
f1040_other_in: forms.F1040.L21 || 0,
f1040_credit_repayment: forms.F1040.L42 || 0, // Form 1040, Line 46
f1040_obamacare_fee: forms.F1040.HLTHPEN || 0, // Form 1040, Line 61
f1040_federal_tax_withheld: forms.F1040.L58 || 0, // Form 1040, Line 64
student_loan_ws_1040_student_loan_interest: forms.F1040.L24 || 0,//Form 1040, Line 33 (this is the number after clamping, FFFF has no place to enter the un-clamped student loan interest)
f1040_sched_a_medical_expenses: forms.FSCHA.L1 || 0,
f1040_sched_a_local_taxes: forms.FSCHA.L5 || 0,
f1040_sched_a_real_estate_taxes: forms.FSCHA.L6 || 0,
f1040_sched_a_property_taxes: forms.FSCHA.L7 || 0,
f1040_sched_a_other_taxes: forms.FSCHA.L8 || 0,
f1040_sched_a_reported_mort_interest: forms.FSCHA.L10 || 0,
f1040_sched_a_unreported_mort_interest: forms.FSCHA.L11 || 0,
f1040_sched_a_unreported_mort_points: forms.FSCHA.L12 || 0,
f1040_sched_a_mort_insurance_premia: forms.FSCHA.QUALMORT || 0,
f1040_sched_a_investment_interest: forms.FSCHA.L13 || 0, // Schedule A, Line 14
f1040_sched_a_charity_cash: forms.FSCHA.L15 || 0, // Schedule A, Line 16
f1040_sched_a_charity_noncash: forms.FSCHA.L16 || 0, // Schedule A, Line 17
f1040_sched_a_charity_carryover: forms.FSCHA.L17 || 0, // Schedule A, Line 18
f1040_sched_a_casualty_or_theft_losses: forms.FSCHA.L19 || 0, // Schedule A, Line 20
f1040_sched_a_employee_expenses: forms.FSCHA.L20 || 0, // Schedule A, Line 21
f1040_sched_a_tax_prep_fees: forms.FSCHA.L21 || 0, // Schedule A, Line 22
f1040_sched_a_other_work_expenses: forms.FSCHA.L22 || 0, // Schedule A, Line 23
f1040_sched_a_other_deductions: forms.FSCHA.L27 || 0, // Schedule A, Line 28
f1040_sched_e_rents_received: (forms.FSCHE1.LINE3B_L3_1_ || 0) + (forms.FSCHE1.LINE3B_L3_2_ || 0) + (forms.FSCHE1.LINE3B_L3_3_ || 0),
f1040_sched_e_royalties_received: (forms.FSCHE1.LINE4_L4_1_ || 0) + (forms.FSCHE1.LINE4_L4_2_ || 0) + (forms.FSCHE1.LINE4_L4_3_ || 0),
f1040_sched_e_advertising: (forms.FSCHE1.LINE5_L5_1_ || 0) + (forms.FSCHE1.LINE5_L5_2_ || 0) + (forms.FSCHE1.LINE5_L5_3_ || 0),
f1040_sched_e_auto_and_travel: (forms.FSCHE1.LINE6AT_L6AT_1_ || 0) + (forms.FSCHE1.LINE6AT_L6AT_2_ || 0) + (forms.FSCHE1.LINE6AT_L6AT_3_ || 0),
f1040_sched_e_cleaning_and_maintenance: (forms.FSCHE1.LINE7_L7_1_ || 0) + (forms.FSCHE1.LINE7_L7_2_ || 0) + (forms.FSCHE1.LINE7_L7_3_ || 0),
f1040_sched_e_commissions: (forms.FSCHE1.LINE8_L8_1_ || 0) + (forms.FSCHE1.LINE8_L8_2_ || 0) + (forms.FSCHE1.LINE8_L8_3_ || 0),
f1040_sched_e_insurance: (forms.FSCHE1.LINE9_L9_1_ || 0) + (forms.FSCHE1.LINE9_L9_2_ || 0) + (forms.FSCHE1.LINE9_L9_3_ || 0),
f1040_sched_e_professional_fees: (forms.FSCHE1.LINE10_L10_1_ || 0) + (forms.FSCHE1.LINE10_L10_2_ || 0) + (forms.FSCHE1.LINE10_L10_3_ || 0),
f1040_sched_e_management_fees: (forms.FSCHE1.LINE11_L11_1_ || 0) + (forms.FSCHE1.LINE11_L11_2_ || 0) + (forms.FSCHE1.LINE11_L11_3_ || 0),
f1040_sched_e_mortgage_interest: (forms.FSCHE1.LINE12_L12_1_ || 0) + (forms.FSCHE1.LINE12_L12_2_ || 0) + (forms.FSCHE1.LINE12_L12_3_ || 0),
f1040_sched_e_other_interest: (forms.FSCHE1.LINE13_L13_1_ || 0) + (forms.FSCHE1.LINE13_L13_2_ || 0) + (forms.FSCHE1.LINE13_L13_3_ || 0),
f1040_sched_e_repairs: (forms.FSCHE1.LINE14_L14_1_ || 0) + (forms.FSCHE1.LINE14_L14_2_ || 0) + (forms.FSCHE1.LINE14_L14_3_ || 0),
f1040_sched_e_supplies: (forms.FSCHE1.LINE15_L15_1_ || 0) + (forms.FSCHE1.LINE15_L15_2_ || 0) + (forms.FSCHE1.LINE15_L15_3_ || 0),
f1040_sched_e_taxes: (forms.FSCHE1.LINE16_L16_1_ || 0) + (forms.FSCHE1.LINE16_L16_2_ || 0) + (forms.FSCHE1.LINE16_L16_3_ || 0),
f1040_sched_e_utilities: (forms.FSCHE1.LINE17_L17_1_ || 0) + (forms.FSCHE1.LINE17_L17_2_ || 0) + (forms.FSCHE1.LINE17_L17_3_ || 0),
f1040_sched_e_depreciation: (forms.FSCHE1.LINE18_L20_1_ || 0) + (forms.FSCHE1.LINE18_L20_2_ || 0) + (forms.FSCHE1.LINE18_L20_3_ || 0),
f1040_sched_e_other_expenses: (forms.FSCHE1.OTHEREXP_L18A_1_ || 0) + (forms.FSCHE1.OTHEREXP_L18B_1_ || 0) + (forms.FSCHE1.OTHEREXP_L18C_1_ || 0),
f8582_ws1_8582_prior_loss: forms.F8582W15.TC1 || 0, // This assumes that all prior year loss entered here is related to rental real estate
};
for (var id in avocados) {
var value = avocados[id];
console.log("if (g._nodes." + id + ") {");
console.log(" g._nodes." + id + ".val = " + value + ";");
console.log(" fixboxsize(g._nodes." + id + ");");
console.log("}");
}
console.log("recalc();")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment