---
source: https://carbone.io/examples/gl-journal-import-csv/
title: "Journal Entry Automation: GL Import CSV from JSON | Carbone"
description: "Automate journal entries: generate a GL journal import CSV from payroll or billing data with the Carbone API, with balanced debits and credits per journal."
generated_at: "2026-11-17"
---

# GL journal import

Payroll accruals from your subledger, as an ERP import CSV

[![GL journal import: CSV generated from a CSV template and JSON data](/examples/gl-journal-import-csv/thumb-result.webp)](/examples/gl-journal-import-csv/result.csv "Download the generated document")

[Download template](/examples/gl-journal-import-csv/template.csv)

[Sample data](/examples/gl-journal-import-csv/data.json)

[Download the generated CSV](/examples/gl-journal-import-csv/result.csv)

- **Template:** CSV
- **Export as:** CSV
- **Carbone:** 5.4+

Features

-   [Loop](/documentation/design/repetitions/with-arrays.md)
-   [Nested array](/documentation/design/repetitions/with-arrays.md)
-   [Condition](/documentation/design/conditions/overview.md)
-   [Number format](/documentation/design/formatters/number.md)
-   [Date format](/documentation/design/formatters/date.md)
-   Parent properties

## Generate journal entry import files from your subledger

Payroll, billing and revenue systems compute the figures, but the general ledger must receive them as journal entries. Most ERPs load them from a CSV file, and finance teams often rebuild that file by hand in a spreadsheet at every month-end close. Your system sends its journals to the Carbone API as JSON and gets back the CSV to import into the ERP, one file for all the journals of the close. In this example, a payroll system posts three journals of November 2026 for a fictional company: the payroll, the bonus accrual, and the PTO and commission accruals.

The layout follows the CSV import of NetSuite journal entries, described in the [Journal Entry CSV Files](https://docs.oracle.com/en/cloud/saas/netsuite/ns-online-help/section_1534489651.html) help: header values repeated on every line, line fields prefixed with `Journal Entry - Line:`, and the lines of one journal sharing the same External ID. Other ERPs expect other column names, so start from the sample file of your own system.

In this example, you will:

-   write one CSV line per journal line, in a loop on the journals and their lines;
-   put each amount in the Debit or the Credit column with a condition;
-   write ISO dates and plain amounts with two decimals;
-   quote the text fields that contain commas or quotes.

## GL journal import file format

| Column | Content |
| --- | --- |
| External ID | The journal reference, identical on all its lines |
| Date, Posting Period | Journal date and accounting period, here 2026-11-30 and Nov 2026 |
| Journal Entry - Line: Account | Account number and name, like `6010 Salaries and Wages` |
| Department | Cost center of the line, empty on balance sheet lines |
| Journal Entry - Line: Debit, Credit | The amount in one of the two columns, a dot as decimal separator, no thousands separator |
| Journal Entry - Line: Memo | Description of the line |
| Subsidiary, Currency, Exchange Rate, Memo, Approved | Header values of the journal, repeated on every line |

## GL journal import example

### Template

```text
{o.lang=en-us}External ID,Date,Posting Period,Journal Entry - Line: Account,Department,Journal Entry - Line: Debit,Journal Entry - Line: Credit,Journal Entry - Line: Memo,Subsidiary,Currency,Exchange Rate,Memo,Approved
{d.journals[i].lines[i].type:ifEQ(debit):showBegin}{d.journals[i].lines[i]..externalId},{d.journals[i].lines[i]..date:formatD('YYYY-MM-DD')},{d.journals[i].lines[i]..postingPeriod},"{d.journals[i].lines[i].account:replace('"', '""')}","{d.journals[i].lines[i].department}",{d.journals[i].lines[i].amount:formatN(2):replace(',', '')},,"{d.journals[i].lines[i].memo:replace('"', '""')}","{d.journals[i].lines[i]..subsidiary}",{d.journals[i].lines[i]..currency},{d.journals[i].lines[i]..exchangeRate:formatN(2)},"{d.journals[i].lines[i]..memo:replace('"', '""')}",{d.journals[i].lines[i]..approved:ifEQ(true):show(T):elseShow(F)}
{d.journals[i].lines[i].type:showEnd}{d.journals[i].lines[i].type:ifEQ(credit):showBegin}{d.journals[i].lines[i]..externalId},{d.journals[i].lines[i]..date:formatD('YYYY-MM-DD')},{d.journals[i].lines[i]..postingPeriod},"{d.journals[i].lines[i].account:replace('"', '""')}","{d.journals[i].lines[i].department}",,{d.journals[i].lines[i].amount:formatN(2):replace(',', '')},"{d.journals[i].lines[i].memo:replace('"', '""')}","{d.journals[i].lines[i]..subsidiary}",{d.journals[i].lines[i]..currency},{d.journals[i].lines[i]..exchangeRate:formatN(2)},"{d.journals[i].lines[i]..memo:replace('"', '""')}",{d.journals[i].lines[i]..approved:ifEQ(true):show(T):elseShow(F)}
{d.journals[i].lines[i].type:showEnd}{d.journals[i+1].lines[i+1]}
```

### JSON data

```json
{
  "journals": [
    {
      "externalId": "PAY-2026-11-A", "date": "2026-11-30", "postingPeriod": "Nov 2026",
      "subsidiary": "Northwind Analytics Inc.", "currency": "USD", "exchangeRate": 1, "approved": false,
      "memo": "November 2026 payroll, gross pay to net pay",
      "lines": [
        { "account": "6010 Salaries and Wages", "department": "Engineering", "type": "debit", "amount": 214380.0, "memo": "Gross wages, pay periods 21 to 22" },
        { "account": "6010 Salaries and Wages", "department": "Sales", "type": "debit", "amount": 142915.5, "memo": "Gross wages, pay periods 21 to 22" },
        { "account": "6010 Salaries and Wages", "department": "Customer Success", "type": "debit", "amount": 91305.0, "memo": "Gross wages, pay periods 21 to 22" },
        { "account": "6010 Salaries and Wages", "department": "General and Administrative", "type": "debit", "amount": 68240.25, "memo": "Gross wages, pay periods 21 to 22" },
        { "account": "6020 Employer Payroll Taxes", "department": "Engineering", "type": "debit", "amount": 16400.07, "memo": "Employer FICA and unemployment taxes" },
        { "account": "6020 Employer Payroll Taxes", "department": "Sales", "type": "debit", "amount": 10933.04, "memo": "Employer FICA and unemployment taxes" },
        { "account": "6020 Employer Payroll Taxes", "department": "Customer Success", "type": "debit", "amount": 6984.83, "memo": "Employer FICA and unemployment taxes" },
        { "account": "6020 Employer Payroll Taxes", "department": "General and Administrative", "type": "debit", "amount": 5220.38, "memo": "Employer FICA and unemployment taxes" },
        { "account": "2000 Net Pay Clearing", "department": "", "type": "credit", "amount": 367990.62, "memo": "Net pay, direct deposit batch PR261130" },
        { "account": "2210 Taxes Withheld, Federal and State", "department": "", "type": "credit", "amount": 111120.76, "memo": "Employee income tax withholding" },
        { "account": "2220 Employer Payroll Taxes Payable", "department": "", "type": "credit", "amount": 39538.32, "memo": "Employer taxes due to agencies" },
        { "account": "2230 401(k) Deferrals Payable", "department": "", "type": "credit", "amount": 23257.83, "memo": "Employee 401(k) contributions" },
        { "account": "2240 Health Premiums Payable", "department": "", "type": "credit", "amount": 14471.54, "memo": "Employee share of health premiums" }
      ]
    },
    {
      "externalId": "PAY-2026-11-B", "date": "2026-11-30", "postingPeriod": "Nov 2026",
      "subsidiary": "Northwind Analytics Inc.", "currency": "USD", "exchangeRate": 1, "approved": false,
      "memo": "November 2026 bonus accrual, 3 departments",
      "lines": [
        { "account": "6015 Bonus Expense", "department": "Engineering", "type": "debit", "amount": 31800.0, "memo": "Q4 "Quota Attainment" plan, November accrual" },
        { "account": "6015 Bonus Expense", "department": "Sales", "type": "debit", "amount": 18450.0, "memo": "Q4 "Quota Attainment" plan, November accrual" },
        { "account": "6015 Bonus Expense", "department": "Customer Success", "type": "debit", "amount": 9275.4, "memo": "Q4 "Quota Attainment" plan, November accrual" },
        { "account": "2150 Accrued Bonuses", "department": "", "type": "credit", "amount": 59525.4, "memo": "Q4 "Quota Attainment" plan, November accrual" }
      ]
    },
    {
      "externalId": "PAY-2026-11-C", "date": "2026-11-30", "postingPeriod": "Nov 2026",
      "subsidiary": "Northwind Analytics Inc.", "currency": "USD", "exchangeRate": 1, "approved": false,
      "memo": "November 2026 PTO and commission accruals",
      "lines": [
        { "account": "6012 Paid Time Off Expense", "department": "Engineering", "type": "debit", "amount": 6120.35, "memo": "Net change in PTO liability" },
        { "account": "6012 Paid Time Off Expense", "department": "Sales", "type": "debit", "amount": 3890.1, "memo": "Net change in PTO liability" },
        { "account": "6012 Paid Time Off Expense", "department": "Customer Success", "type": "debit", "amount": 2415.75, "memo": "Net change in PTO liability" },
        { "account": "6012 Paid Time Off Expense", "department": "General and Administrative", "type": "debit", "amount": 1764.2, "memo": "Net change in PTO liability" },
        { "account": "6016 Sales Commissions", "department": "Sales", "type": "debit", "amount": 12640.8, "memo": "Commissions earned, deals closed in November" },
        { "account": "2160 Accrued Paid Time Off", "department": "", "type": "credit", "amount": 14190.4, "memo": "PTO liability at November 30" },
        { "account": "2155 Accrued Commissions, Payable Next Month", "department": "", "type": "credit", "amount": 12640.8, "memo": "Paid with the December 15 payroll" }
      ]
    }
  ]
}
```

### Generated CSV

```text
External ID,Date,Posting Period,Journal Entry - Line: Account,Department,Journal Entry - Line: Debit,Journal Entry - Line: Credit,Journal Entry - Line: Memo,Subsidiary,Currency,Exchange Rate,Memo,Approved
PAY-2026-11-A,2026-11-30,Nov 2026,"6010 Salaries and Wages","Engineering",214380.00,,"Gross wages, pay periods 21 to 22","Northwind Analytics Inc.",USD,1.00,"November 2026 payroll, gross pay to net pay",F
PAY-2026-11-A,2026-11-30,Nov 2026,"6010 Salaries and Wages","Sales",142915.50,,"Gross wages, pay periods 21 to 22","Northwind Analytics Inc.",USD,1.00,"November 2026 payroll, gross pay to net pay",F
PAY-2026-11-A,2026-11-30,Nov 2026,"6010 Salaries and Wages","Customer Success",91305.00,,"Gross wages, pay periods 21 to 22","Northwind Analytics Inc.",USD,1.00,"November 2026 payroll, gross pay to net pay",F
PAY-2026-11-A,2026-11-30,Nov 2026,"6010 Salaries and Wages","General and Administrative",68240.25,,"Gross wages, pay periods 21 to 22","Northwind Analytics Inc.",USD,1.00,"November 2026 payroll, gross pay to net pay",F
PAY-2026-11-A,2026-11-30,Nov 2026,"6020 Employer Payroll Taxes","Engineering",16400.07,,"Employer FICA and unemployment taxes","Northwind Analytics Inc.",USD,1.00,"November 2026 payroll, gross pay to net pay",F
PAY-2026-11-A,2026-11-30,Nov 2026,"6020 Employer Payroll Taxes","Sales",10933.04,,"Employer FICA and unemployment taxes","Northwind Analytics Inc.",USD,1.00,"November 2026 payroll, gross pay to net pay",F
PAY-2026-11-A,2026-11-30,Nov 2026,"6020 Employer Payroll Taxes","Customer Success",6984.83,,"Employer FICA and unemployment taxes","Northwind Analytics Inc.",USD,1.00,"November 2026 payroll, gross pay to net pay",F
PAY-2026-11-A,2026-11-30,Nov 2026,"6020 Employer Payroll Taxes","General and Administrative",5220.38,,"Employer FICA and unemployment taxes","Northwind Analytics Inc.",USD,1.00,"November 2026 payroll, gross pay to net pay",F
PAY-2026-11-A,2026-11-30,Nov 2026,"2000 Net Pay Clearing","",,367990.62,"Net pay, direct deposit batch PR261130","Northwind Analytics Inc.",USD,1.00,"November 2026 payroll, gross pay to net pay",F
PAY-2026-11-A,2026-11-30,Nov 2026,"2210 Taxes Withheld, Federal and State","",,111120.76,"Employee income tax withholding","Northwind Analytics Inc.",USD,1.00,"November 2026 payroll, gross pay to net pay",F
PAY-2026-11-A,2026-11-30,Nov 2026,"2220 Employer Payroll Taxes Payable","",,39538.32,"Employer taxes due to agencies","Northwind Analytics Inc.",USD,1.00,"November 2026 payroll, gross pay to net pay",F
PAY-2026-11-A,2026-11-30,Nov 2026,"2230 401(k) Deferrals Payable","",,23257.83,"Employee 401(k) contributions","Northwind Analytics Inc.",USD,1.00,"November 2026 payroll, gross pay to net pay",F
PAY-2026-11-A,2026-11-30,Nov 2026,"2240 Health Premiums Payable","",,14471.54,"Employee share of health premiums","Northwind Analytics Inc.",USD,1.00,"November 2026 payroll, gross pay to net pay",F
PAY-2026-11-B,2026-11-30,Nov 2026,"6015 Bonus Expense","Engineering",31800.00,,"Q4 ""Quota Attainment"" plan, November accrual","Northwind Analytics Inc.",USD,1.00,"November 2026 bonus accrual, 3 departments",F
PAY-2026-11-B,2026-11-30,Nov 2026,"6015 Bonus Expense","Sales",18450.00,,"Q4 ""Quota Attainment"" plan, November accrual","Northwind Analytics Inc.",USD,1.00,"November 2026 bonus accrual, 3 departments",F
PAY-2026-11-B,2026-11-30,Nov 2026,"6015 Bonus Expense","Customer Success",9275.40,,"Q4 ""Quota Attainment"" plan, November accrual","Northwind Analytics Inc.",USD,1.00,"November 2026 bonus accrual, 3 departments",F
PAY-2026-11-B,2026-11-30,Nov 2026,"2150 Accrued Bonuses","",,59525.40,"Q4 ""Quota Attainment"" plan, November accrual","Northwind Analytics Inc.",USD,1.00,"November 2026 bonus accrual, 3 departments",F
PAY-2026-11-C,2026-11-30,Nov 2026,"6012 Paid Time Off Expense","Engineering",6120.35,,"Net change in PTO liability","Northwind Analytics Inc.",USD,1.00,"November 2026 PTO and commission accruals",F
PAY-2026-11-C,2026-11-30,Nov 2026,"6012 Paid Time Off Expense","Sales",3890.10,,"Net change in PTO liability","Northwind Analytics Inc.",USD,1.00,"November 2026 PTO and commission accruals",F
PAY-2026-11-C,2026-11-30,Nov 2026,"6012 Paid Time Off Expense","Customer Success",2415.75,,"Net change in PTO liability","Northwind Analytics Inc.",USD,1.00,"November 2026 PTO and commission accruals",F
PAY-2026-11-C,2026-11-30,Nov 2026,"6012 Paid Time Off Expense","General and Administrative",1764.20,,"Net change in PTO liability","Northwind Analytics Inc.",USD,1.00,"November 2026 PTO and commission accruals",F
PAY-2026-11-C,2026-11-30,Nov 2026,"6016 Sales Commissions","Sales",12640.80,,"Commissions earned, deals closed in November","Northwind Analytics Inc.",USD,1.00,"November 2026 PTO and commission accruals",F
PAY-2026-11-C,2026-11-30,Nov 2026,"2160 Accrued Paid Time Off","",,14190.40,"PTO liability at November 30","Northwind Analytics Inc.",USD,1.00,"November 2026 PTO and commission accruals",F
PAY-2026-11-C,2026-11-30,Nov 2026,"2155 Accrued Commissions, Payable Next Month","",,12640.80,"Paid with the December 15 payroll","Northwind Analytics Inc.",USD,1.00,"November 2026 PTO and commission accruals",F
```

## How to create a journal import file

### 1\. Write the header line and one line per journal line

Type the header as the ERP expects it. The journals contain lines, so the body is a [nested loop](/documentation/design/template-formats/csv.md#loops-nested-data): `{d.journals[i].lines[i].account}` writes the account of each line, and `{d.journals[i].lines[i]..externalId}` reads the External ID of its journal with two dots. Both loops end with `{d.journals[i+1].lines[i+1]}`, at the start of the last template line.

### 2\. Choose the Debit or the Credit column

The subledger sends one `amount` and a `type`. Each line has two versions in the template, wrapped in [conditional blocks](/documentation/design/conditions/conditional-blocks.md#showbegin-showend): `{d.journals[i].lines[i].type:ifEQ(debit):showBegin}` keeps the version with the amount in the Debit column, and `{d.journals[i].lines[i].type:ifEQ(credit):showBegin}` the one with the amount in the Credit column. The other column stays empty, like `214380.00,,`.

### 3\. Format dates and numbers

`{o.lang=en-us}` at the start of the file fixes the number format. `{d.journals[i].lines[i].amount:formatN(2):replace(',', '')}` writes `214380.00`, and `{d.journals[i].lines[i]..date:formatD('YYYY-MM-DD')}` writes `2026-11-30`. `{d.journals[i].lines[i]..approved:ifEQ(true):show(T):elseShow(F)}` turns the boolean into the `T` or `F` of the Approved column.

### 4\. Quote the text fields

Account names, memos and departments can contain a comma or a quote: `2210 Taxes Withheld, Federal and State`. They are written between quotes, and `:replace('"', '""')` doubles the quotes inside the value, so `Q4 "Quota Attainment" plan` is read back as one field. See [Commas and quotes](/documentation/design/template-formats/csv.md#commas-and-quotes).

### 5\. Import the file

The file is UTF-8 without BOM, with one header line and 24 lines. Each journal balances: 556,379.07 for the payroll, 59,525.40 for the bonus accrual and 26,831.20 for the accruals. In NetSuite, run **Setup > Import/Export > Import CSV Records**, with the import type **Transactions** and the record type **Journal Entry**, and map the columns. Create the Carbone call in the payroll system, so that the file is ready when the close starts.

## Related Examples

- [Excel payroll register](/examples/payroll-register/index.md): XLSX template to XLSX.
- [NACHA ACH file](/examples/nacha-ach-file/index.md): TXT template to ACH.
- [Accounts receivable aging report](/examples/accounts-receivable-aging-report/index.md): XLSX template to XLSX.

## Related topics

- [Positive Pay file](/examples/positive-pay-file-csv/index.md)
- [Utility invoice with payment slip](/examples/invoice-expert/index.md)
- [Bank statement with page subtotals](/examples/bank-statement-simple/index.md)
- [Checking account statement](/examples/bank-statement-expert/index.md)
- [Monthly fund factsheet](/examples/fund-factsheet/index.md)
- [Multi-page product invoice](/examples/invoice-simple/index.md)
