FlowKit

n8n Convert to File node: turn JSON items into real files (guide)

Published 26 August 2026 · 7 min read

An n8n workflow can query a database, filter, enrich and score thousands of rows without ever leaving the world of JSON. Then comes the last metre: sending a report as an attachment, dropping an export on a bucket, answering a webhook with a downloadable document. JSON is no longer enough — you need a real file, with a name, an extension and a MIME type. That is the job of the Convert to File node (n8n-nodes-base.convertToFile). This guide walks through its ten operations, the options that actually matter, its mirror node Extract from File, and the mistakes that sink an otherwise perfect workflow right before the finish line.

The data model: json on one side, binary on the other

Every n8n item is an object with two possible keys. The json key carries the structured data most nodes manipulate; the binary key carries files, as one or more named binary propertiesdata by default, though nothing forces you to stick with it. Each binary property exposes documented fields: data (the content, base64-encoded internally), mimeType, fileName, fileExtension, fileSize, fileType and id.

{
  "json": { "customer": "Dupont", "amount": 1250 },
  "binary": {
    "data": {
      "fileName": "report-2026-08.csv",
      "mimeType": "text/csv",
      "fileExtension": "csv",
      "fileSize": "18 kB"
    }
  }
}

Nearly every file-related problem in n8n boils down to a badly named binary property, a missing mimeType or a fileName without an extension. Convert to File is the tool that fills those fields in.

The ten operations of the Convert to File node

The tabular formats: CSV, XLSX, ODS, XLS, HTML, RTF

Six operations turn the item list into a table: Convert to CSV, Convert to XLSX, Convert to XLS, Convert to ODS, Convert to HTML (which produces an HTML table) and Convert to RTF. All share the required Put Output File in Field parameter, which says which binary property receives the result — data by default — plus the File Name and Header Row options (off by default): without the latter, your CSV ships with no header row. The spreadsheet operations add Sheet Name; XLSX and ODS also offer Compression.

One thing to know: Convert to CSV exposes no delimiter option, and the file it produces uses commas. If your recipient insists on semicolons — the common case with a French-configured Excel — build the string yourself in a Code node then use Convert to Text File, or simply deliver an XLSX. This dialect question is anything but anecdotal: in "Wrangling messy CSV files by detecting row and type patterns", published in 2019 in Data Mining and Knowledge Discovery, Gerrit J. J. van den Burg, Alfredo Nazábal and Charles Sutton show that automatically detecting the delimiter, quote character and escape character fails regularly on real-world files, and propose a method that improves accuracy by nearly 22% on messy CSVs (see on Google Scholar). A CSV is never as universal as it looks, and shipping an XLSX removes that entire class of bugs.

Convert to JSON: the Mode parameter changes everything

The Convert to JSON operation stands apart: instead of Put Output File in Field, it exposes a Mode parameter with two values:

  • All Items to One File — a single .json file holding the complete array of items;
  • Each Item to Separate File — one file per item, hence as many output items.

The options are File Name, Format (which indents the JSON, off by default) and Encoding (utf8 by default). Per-item mode is for archiving each record separately; it becomes a trap when you wanted a single export and end up with 4,000 files to upload one at a time.

Convert to Text File and Convert to ICS

Convert to Text File takes a Text Input Field parameter: the JSON field whose content becomes the file. This is the operation for anything you composed yourself — Markdown generated by an LLM, XML assembled upstream, a CSV with an exotic delimiter. Options: File Name and Encoding.

Convert to ICS generates an iCalendar file from Event Title and Start, rounded out by End (which falls back to the start date if omitted) and All Day. The options cover a genuine event: Attendees, Description, Location, Organizer, Recurrence Rule, Busy Status, Calendar Name, UID and Use Workflow Timezone. Attached to a booking confirmation, an .ics drops into Outlook or Google Calendar in one click.

Move Base64 String to File: the operation that saves integrations

Plenty of APIs do not return a file but a base64 string inside a JSON field — an invoice PDF, an e-signature, a generated image. Move Base64 String to File takes a Base64 Input Field parameter (the field path, in dot notation) and two options: File Name and MIME Type. Do not skip the latter: without it the file travels with no declared type and downstream behaviour becomes unpredictable — an attachment shown as application/octet-stream, the wrong Content-Type served by object storage, a browser downloading instead of displaying.

// Strip a data URI before Move Base64 String to File
const raw = $json.document.content;
return [{ json: { b64: raw.replace(/^data:[^;]+;base64,/, '') } }];

Extract from File: the mirror node

The Extract from File node walks the path in reverse: it takes a binary property (Input Binary Field parameter, data by default) and outputs JSON. Its operations cover Extract From CSV, XLSX, XLS, ODS, JSON, HTML, ICS, PDF, RTF, Text File, plus Move File to Base64 String. Several expose a Destination Output Field to pick where the result lands.

Extract and Convert form a complete round trip, detailed in our guide to extracting and generating Excel and CSV files: read an XLSX dropped on Drive, transform the rows, write a clean XLSX back out. Do not confuse either of them with the Read/Write Files from Disk node, the only one of the three that actually touches the instance's file system.

Aggregate upstream, the loop as a trap

The tabular operations natively group every incoming item into a single file. But as soon as you need to reshape the structure before exporting — keeping only certain fields, flattening a nested array, grouping by customer — the Aggregate node becomes the natural preliminary step, as our guide to the Split Out and Aggregate nodes explains. The symmetrical trap is sneakier: placing Convert to File inside a Loop Over Items loop. The node then runs once per batch and produces that many partial files, without raising a single error — ten emails go out with ten incomplete CSVs.

Five use cases

  • Weekly report as an attachment: Convert to CSV, Header Row on, a dated File Name, then a send through the SMTP node pointing at data;
  • XLSX export dropped on storage: Convert to XLSX with an explicit Sheet Name, then an upload to Google Drive or an S3 archive;
  • JSON audit trail: Convert to JSON in All Items to One File mode, Format option on, dropped on a write-only SFTP. The format is not neutral for that kind of archive: back in 2009, Nurzhan Nurseitov, Michael Paulson, Randall Reynolds and Clemente Izurieta measured in "Comparison of JSON and XML Data Interchange Formats: A Case Study", presented at the CAINE conference, that JSON serialised and transmitted the same objects an order of magnitude faster than XML — an old study, but one whose performance gap has never been overturned (see on Google Scholar);
  • Booking confirmation: Convert to ICS with Attendees and Location set, attached to the email;
  • Supplier PDF in base64: Move Base64 String to File with application/pdf as MIME Type, upstream of a quote and invoice PDF generation pipeline.

The classic traps

  • Confusing Convert to File with Read/Write Files from Disk: the former creates no file on the server. No point looking for the CSV in /tmp — it only lives inside the item;
  • The missing MIME type: after a Move Base64 String to File with no MIME Type option, the attachment arrives as application/octet-stream, some antispam filters block it and the recipient has to rename it by hand;
  • A name with no extension: report instead of report.csv. Windows does not know what to do with it and several storage APIs reject the object;
  • Overwriting the data binary property: two consecutive Convert to File nodes both writing into data yield a single file, the second one. Change Put Output File in Field (invoice, annex) — that is also the prerequisite for zipping both at once with the Compression node;
  • UTF-8 and Excel: a UTF-8 CSV double-clicked on Windows shows broken accents. XLSX settles the question;
  • Memory on large volumes: every generated file occupies RAM for the whole execution. On heavy exports, switch N8N_DEFAULT_BINARY_DATA_MODE to filesystem (handling large files);
  • Answering a webhook with a file: the Respond to Webhook node must be set to a binary response and point at the right binary property, otherwise the client receives JSON.

Key takeaways

Convert to File is the hinge between n8n's JSON and everything that expects a real file. Three settings do most of the work: Put Output File in Field, File Name (with the extension) and, for tabular formats, Header Row. Add MIME Type for Move Base64 String to File and Mode for Convert to JSON. The rest — Extract from File for the return trip, Aggregate for grouping, filesystem mode for volume — follows from the need.

Going further

Generating the right file is rarely an end in itself: it is the last step of a processing chain. The Compliance & Audit Pack (€149) shows how that export becomes supporting evidence — a timestamped JSON log, an archived CSV report, a trail dropped on external storage. The AI Inbox Pack (€79) illustrates the opposite path: extract the data from an incoming attachment, process it, then send a clean file back.

FAQ

Frequently asked questions

What is the difference between Convert to File and Read/Write Files from Disk?

Convert to File builds a file in memory: it takes JSON items and produces binary data attached to the item, without ever touching the file system. Read/Write Files from Disk reads or writes a file on the n8n instance's disk. The two complement each other: Convert to File generates the content, Read/Write Files puts it on disk if you actually need that. For an email send, an S3 upload or a webhook response, going through the disk is pointless.

How do I generate a single CSV file from several n8n items?

The Convert to CSV operation natively aggregates every incoming item into one file, one row per item: no extra node is needed. Aggregate becomes useful for the Convert to JSON operation, whose Mode parameter offers All Items to One File or Each Item to Separate File. If you still end up with one file per item, check that the node is not sitting inside a Loop Over Items loop, which makes it run batch by batch.

Why do accented characters look wrong in my CSV when opened in Excel?

The file n8n produces is UTF-8 encoded, but Excel on Windows assumes the machine's regional encoding when you double-click a .csv. Accented characters then show up as unreadable sequences. Two reliable workarounds: deliver a proper XLSX through the Convert to XLSX operation, which has no encoding ambiguity at all, or ask the recipient to use Excel's data import wizard and explicitly pick UTF-8.

How do I turn a base64 string returned by an API into a file in n8n?

Use the Move Base64 String to File operation of the Convert to File node. Set Base64 Input Field to the path of the field holding the string, for example data.content or document.base64. In the options, set File Name and above all MIME Type: without it the file carries no declared type, and some mail clients or storage services reject it or rename it. If the string carries a data:application/pdf;base64 prefix, strip it with an Edit Fields node before converting.

Bundle FlowKit Complet

€269