---
title: Convert to File
description: Turn items into a file (CSV, JSON, text, base64 or binary)
---

Turn your items into a file (CSV, JSON, text, base64 or binary) that later nodes can upload, attach or save.

## What it does

Convert to File builds one file from **all** incoming items and attaches it to a single output item. It does not save the file anywhere: that is the job of the next node, such as [Google Drive](/nodes/builtin/integration/google-drive/), an [Http Request](/nodes/builtin/core/http-request/) body, or a Slack or Gmail attachment.

The file name and type default to sensible values per format (`data.csv` and `text/csv`, `data.json` and `application/json`, `data.txt` and `text/plain`, `data.bin` and `application/octet-stream`).

## When to use it

* Upload a scraped table to Google Drive as a real CSV file.
* Attach generated JSON or text to a Slack message or an email.
* Turn a base64 string returned by an API into a proper file.
* To save generated text (CSV, JSON, Markdown) straight to your computer, use [Save as File](/nodes/builtin/datatransformation/saveasfile/) instead.

## Inputs and settings

How each **Format** builds the file:

* **CSV**: one row per item, written the same way as the [CSV](/nodes/builtin/datatransformation/csv/) node.
* **JSON**: all items as a neatly indented JSON list.
* **Text**: one line per item. With **Source Field** set, each line is that field's value; otherwise text items are used as is and other items are written as JSON.
* **Base64**: decodes the base64 text from **Source Field** (or the `data` field) of the first item. Base64 says nothing about the file type, so set **MIME type**, for example `application/pdf`.
* **Binary**: re-wraps a file already attached to the first item (by default under `data`), keeping its own name and type unless you set new ones.

## Outputs

Each output item has these fields:

```json title="Shape of an output item"
{
  "fileName": "…",
  "mimeType": "…",
  "format": "…",
  "size": 0,
  "$binary": {}
}
```

One item that carries the file under `data`, plus its name, type and size in bytes. In the next node, choose this file as the binary or attachment source.

## Dependencies and credentials

None. This node needs no connection and has no slots for other nodes.

## Example workflow

1. [HTML Extract](/nodes/builtin/datatransformation/html-extract/) reads a product table from a page, one item per row.
2. Convert to File with **Format** *CSV* and **File name** `products.csv`.
3. [Google Drive](/nodes/builtin/integration/google-drive/) uploads the file using this node's file as the source.

## Common issues

* **"No items to convert. Connect a node that produces items."** Nothing reached the node. Check that the previous node returns data.
* **"Base64 needs a base64 string."** Name the field holding the base64 text in **Source Field**, or put it in a `data` field, and make sure it is text.
* **"No binary to wrap."** With *Binary*, the first item has no attached file. Connect a node that outputs a file, or name the field holding it in **Source Field**.
* **The file opens with the wrong app or type.** Set **MIME type** yourself. This matters most for *Base64*, which otherwise becomes `application/octet-stream`.

## Related nodes

* [Save as File](/nodes/builtin/datatransformation/saveasfile/): save generated text to your computer.
* [Extract From File](/nodes/builtin/datatransformation/extractfromfile/): the opposite, read a file back into items.
* [Compression](/nodes/builtin/datatransformation/compression/): gzip the file before sending it.
* [CSV](/nodes/builtin/datatransformation/csv/): turn items into CSV text instead of a file.