A Python script that parses the 1099-B section of a consolidated 1099 PDF from supported brokers and generates a TXF (Tax Exchange Format) file for import into tax software such as H&R Block or TurboTax.
This tool is provided for informational purposes only and is not tax advice. You are responsible for verifying the accuracy of all generated data before and after importing into tax software or filing with the IRS.
Use at your own risk.
python 1099b_to_txf.py your_1099.pdfThis generates a .txf file that can be imported into your tax software.
- Parses consolidated 1099 PDFs from supported brokers
- Extracts 1099-B transaction data
- Generates TXF files compatible with tax software
- Groups transactions using IRS-accepted VAR-S / VAR-L rules
- Provides a terminal preview for verification before import
- Morgan Stanley — consolidated 1099 PDF
- Fidelity — consolidated 1099 PDF (Fidelity Brokerage Services LLC)
Additional brokers can be added by implementing a new parser and extending detect_broker().
- Short-term covered securities (Box A, Form 8949 Part I)
- Long-term covered securities (Box D, Form 8949 Part II)
- H&R Block uses codes
321/323 - TurboTax typically uses
BD/BE(implemented but not fully tested)
- H&R Block uses codes
git clone https://github.com/jeff162/1099b-pdf-to-txf.git
cd 1099b-pdf-to-txf
pip install -r requirements.txt- Python 3.10+
- pdfplumber (see requirements.txt)
python 1099b_to_txf.py <input.pdf> [output.txf] [--tt] [--swap|--no-swap]input.pdf— path to your consolidated 1099 PDFoutput.txf— optional output file path (defaults to same name as input)--tt— format output for TurboTax (default is H&R Block)--swap/--no-swap— override proceeds/cost basis field order
python 1099b_to_txf.py consolidated_1099.pdfpython 1099b_to_txf.py consolidated_1099.pdf --tt- Go to File → Import Financial Information
- Select the generated
.txffile - Verify imported transactions
- Go to Federal → Wages & Income → Investment Income → Stocks, Crypto, etc.
- Choose I'll type it in myself → Import from TXF file
- Select the generated
.txffile - Verify imported transactions
The script prints a summary table to the terminal so you can verify results before importing:
Reading PDF: DownloadedData.pdf
Detected broker format: morgan_stanley
Found 146 transactions (68 short-term, 78 long-term)
Grouped into 24 TXF records
...
Short-term and long-term subtotals can be cross-checked against your 1099 summary.
Where eligible, transactions are grouped using IRS-accepted date labels:
VAR-S(short-term)VAR-L(long-term)
- Lots of the same security and term are grouped
- Wash sale ≥ $0.50 → disables grouping for that security
- Wash sale < $0.50 → treated as zero
| Feature | H&R Block (default) | TurboTax (--tt) |
|---|---|---|
| TXF record codes | 321, 323 |
BD, BE |
| Field order | Cost basis first | Proceeds first |
- H&R Block behavior was validated empirically
- TurboTax support is implemented but not fully validated
- Consolidated 1099 PDF from a supported broker
- Must include the 1099-B section
- Should be a digital PDF (not scanned)
MIT License
Parts of this project were initially generated with the assistance of AI and later reviewed and refined.