# Convert to File

> Turn a list of records or text into a CSV, Excel (.xlsx), JSON, JSON Lines, HTML table, or plain-text file that downstream Steps can send or upload.

**Convert to File** (`convertToFile`) packages records or text from your automation into a file (`{{ N.file }}`). Downstream Steps can attach the file to an email, upload it to Google Drive or Slack, or store it in your workspace.

**At a glance**

- **Use it to:** Turn a list of records or text into a CSV, Excel (.xlsx), JSON, JSONL, HTML, or text file
- **Find it:** Tools → Data → Convert → Convert to File
- **Cost:** 5 Step credits per started 10 MB
- **Limits:** 100,000 max input rows · 20 MiB max generated file size
- **Output:** {{ N.file }} (with id, name, contentType, and size)
- **Instead:** Respond to Webhook (when returning JSON or text directly to an HTTP caller)

## Setting it up

### Add Convert to File

Open **Tools → Data → Convert** in the dock and select **Convert to File**.

### Choose the file type and input

Set **File type** (`operation`):

| File type         | Value     | Input field            | What it creates                                                                   |
| :---------------- | :-------- | :--------------------- | :-------------------------------------------------------------------------------- |
| **CSV** (default) | `"csv"`   | **Records** (`source`) | UTF-8 `.csv` spreadsheet from a list of records (or a plain list of values).      |
| **Excel (.xlsx)** | `"xlsx"`  | **Records** (`source`) | `.xlsx` workbook with typed numbers, booleans, and text cells.                    |
| **JSON**          | `"json"`  | **Records** (`source`) | Pretty-printed `.json` file (`2`-space indentation) from a list or single record. |
| **JSON Lines**    | `"jsonl"` | **Records** (`source`) | `.jsonl` file with one JSON record per line.                                      |
| **Text**          | `"text"`  | **Text** (`text`)      | UTF-8 `.txt` file containing the exact text you supply.                           |
| **HTML**          | `"html"`  | **Text** (`text`)      | UTF-8 `.html` file (`text/html`) containing the HTML markup you supply.           |

### Customize the filename and tabular options (optional)

Under **Optional Props**:

- **File name** (`fileName`): Base name such as `monthly-report` or `orders-{{ $today }}.csv` (up to `200` characters, defaults to `export`). Glow appends the matching `.csv`, `.xlsx`, `.json`, `.jsonl`, `.txt`, or `.html` extension when omitted.
- **Separator** (`delimiter`, CSV only): **Comma** (`"comma"`, default), **Semicolon** (`"semicolon"`), or **Tab** (`"tab"`).
- **Start with a row of column names** (`includeHeader`, CSV and Excel): Enabled by default (`true`). Columns follow the first record's keys, then any extra keys on later records.
- **Sheet name** (`sheetName`, Excel only): Worksheet tab name (up to `31` characters, defaults to `Sheet1`).

> **Spreadsheet formula-injection protection:** In CSV exports, text values
> starting with `=`, `+`, `-`, or `@` (except plain numbers) are prefixed with a
> single quote (`'`). Excel exports write text cells as inline strings so
> formulas never execute automatically.

> **Do not write credentials into generated files.** Workspace secrets and API keys (`{{ $secret.* }}`, `{{ $key.* }}`, or sealed variables) are refused with `SECRET_IN_UNSAFE_SINK`.

## What it passes on

If **Convert to File** is Step 3, downstream Steps map `{{ 3.file }}` directly into any file attachment or upload field:

| Reference                  | Type   | What it holds                                                                                                             |
| :------------------------- | :----- | :------------------------------------------------------------------------------------------------------------------------ |
| `{{ 3.file }}`             | File   | The complete file reference object to map into a downstream file field.                                                   |
| `{{ 3.file.id }}`          | Text   | Internal storage identifier for the generated file.                                                                       |
| `{{ 3.file.name }}`        | Text   | Sanitized filename including extension (for example `"export.xlsx"`).                                                     |
| `{{ 3.file.contentType }}` | Text   | MIME type (such as `"text/csv; charset=utf-8"` or `"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"`). |
| `{{ 3.file.size }}`        | Number | Size of the generated file in bytes.                                                                                      |

## Limits

| Resource                        | Limit                           |
| :------------------------------ | :------------------------------ |
| **Maximum input rows**          | **100,000** records             |
| **Maximum generated file size** | **20 MiB** (`20,971,520` bytes) |
| **Excel sheet name length**     | `1` to `31` characters          |

## Examples to copy

  

**Export filtered records to Excel**

    Filter a list of orders, build an `.xlsx` spreadsheet, and send it in Slack:

    1. Filter the list in Step 2 using [Filter](https://docs.getglow.ai/build/action-steps/filter-items).
    2. Add **Convert to File** at Step 3 with **File type: Excel (.xlsx)**, **Records**: `{{ 2.kept }}`, **File name**: `orders-{{ $today }}.xlsx`, and **Sheet name**: `Orders`.
    3. Pass `{{ 3.file }}` to your destination app's file upload field in Step 4.

  

  

**Save an AI report as a text file**

    Turn a markdown or plain-text summary from [AI Prompt](https://docs.getglow.ai/build/ai-features/ai-prompt) into a downloadable `.txt` file:

    1. Generate the report in Step 2 with **AI Prompt**.
    2. Add **Convert to File** at Step 3 with **File type: Text**, **Text**: `{{ 2.result }}`, and **File name**: `weekly-brief-{{ $today }}.txt`.
    3. Map `{{ 3.file }}` into an email attachment or cloud-storage upload Step.

  

**Verify it works**

- **Run:** Select a File type, map your Records or Text input, and click Run step in Test & Debug
- **You should see:** The Step outputs {{ N.file }} with its generated name, contentType, and size in bytes, ready to map into an upload or attachment field.

## What's Next?

- Read rows or text back out of an uploaded or downloaded file with [Extract from File](https://docs.getglow.ai/build/action-steps/extract-from-file).
- Reshape, rename, or remove columns before exporting with [Change Fields](https://docs.getglow.ai/build/action-steps/change-fields).
