n8n-binary-and-data
Ce qu’il fait
Cette skill explique comment n8n stocke le contenu des fichiers séparément des données ordinaires, et comment lire, transmettre et envoyer correctement les fichiers. Elle s'adresse aux personnes qui créent des automatisations n8n qui travaillent avec des pièces jointes ou des fichiers envoyés.
Quand l’utiliser
- ✓Quand un workflow n8n télécharge un fichier et que l'étape suivante ne trouve pas son contenu.
- ✓Quand vous voulez qu'un agent IA lise un PDF ou examine une image.
- ✓Quand une étape Merge semble perdre une pièce jointe.
Lien du skill
https://github.com/czlonkowski/n8n-mcp/blob/main/data/skills/n8n-binary-and-data/SKILL.mdCopiez-le et collez-le dans votre IA (Claude, ChatGPT ou Cursor) en lui demandant de suivre les instructions.
Comment l’utiliser
Le plus simple : copiez le message et collez-le dans votre IA. Elle lit le skill et suit les instructions.
Message prêt à coller
Pour Claude Code, Codex ou Cursor : lancez-la dans le dossier du projet et le skill est installé.
Téléchargez le SKILL.md et placez-le dans le dossier de skills de votre agent.
Exemple de demande à votre IA
“Je voudrais corriger mon workflow n8n, qui perd la pièce jointe PDF après l'étape Merge.”
5 nouveaux skills par semaine. 1 minute de lecture.
Comment ça marche
La skill explique où se trouvent les données de fichier dans chaque élément du workflow, et montre comment les lire, les conserver et les envoyer, y compris en transmettant les fichiers par lien quand un chat ou un outil d'IA en a besoin.
Contenu technique (SKILL.md original)
Texte original de l’auteur, en anglais, directement depuis GitHub.
n8n Binary and Data
Every n8n item carries two independent slots: $json for structured data and $binary for file bytes. They travel side by side through the workflow. File contents — the actual PDF, image, or zip — live in $binary, never in $json. Get that split wrong and you read an empty field, lose a file mid-flow, or hand an AI agent a tool input it can't use.
This skill covers where binary lives, how to read and write it, how to keep it from being silently stripped, the hard wall between binary and the AI-agent tool boundary, and why chat surfaces need a URL instead of raw bytes.
The three rules that prevent 90% of binary bugs
File contents are in
$binary, not$json. After an HTTP download, a "Read Files", or an email-attachment trigger, the bytes sit in$binary.<key>.$jsonholds metadata at most. Reading$json.datafor file contents gives you nothing.Binary cannot cross the AI-agent tool boundary — in either direction. Tool arguments and tool return values are JSON only. An uploaded image can't be passed into a tool as a file, and a tool can't return raw bytes. Pre-stage to storage and pass a key or URL through JSON instead. See
AGENT_TOOL_BINARY.md.Chat surfaces render images by URL, not by
$binary. Slack, Discord, Teams, Telegram, embedded webhook chat — none of them read the binary slot. The image has to live somewhere a URL can fetch it. SeeCDN_REQUIREMENT.md.
The two slots
Each item is shaped like this:
{
"json": { "customerId": 42, "status": "sent" },
"binary": {
"invoice": {
"data": "<base64-encoded bytes>",
"mimeType": "application/pdf",
"fileName": "invoice-42.pdf",
"fileExtension": "pdf"
}
}
}
The key inside binary (invoice here) is the binary property name. Most file-handling nodes have a binaryPropertyName parameter that points at it — the producer names the slot, the consumer references it by that name. The default key across most nodes is data, so when nothing tells you otherwise, assume $binary.data.
$json and $binary are separate namespaces. An expression like {{ $binary.invoice.fileName }} reads file metadata; {{ $json.customerId }} reads data. They never mix.
This split also explains a webhook gotcha: a Webhook trigger receiving multipart/form-data puts the uploaded file in $binary and the accompanying form fields in $json.body — so an uploaded file is not somewhere under $json at all. (The $json.body nesting for webhooks is n8n-expression-syntax territory.)
See BINARY_BASICS.md for the full slot anatomy, mime types, and size limits.
Producing binary
You rarely build a $binary slot by hand — nodes populate it for you:
| Source | How binary appears |
|---|---|
HTTP Request with responseFormat: "file" |
Response body lands in $binary.data (or the name you set) |
| Read/Write Files from Disk | File contents read into $binary |
| Storage downloads (S3, Google Drive, Dropbox, etc.) | Downloaded file in $binary.<key> |
| Email triggers with attachments | Each attachment arrives in $binary |
| Provider AI media nodes (image/audio gen) | Set options.binaryPropertyOutput so the bytes land where the next node looks |
For an HTTP download, the one field that matters is responseFormat. Confirm it with get_node on nodes-base.httpRequest — leaving it as the default JSON/string format is the classic reason a downloaded file ends up as garbled text in $json instead of clean bytes in $binary.
Reading and writing binary in a Code node
Most workflows never need to crack open the bytes — they just pass binary through to a consumer (email attachment, file upload, Slack file). When you do need the raw bytes, do it in a Code node.
Read with getBinaryDataBuffer — do not try to base64-decode $binary.<key>.data by hand:
// Code node, "Run Once for Each Item"
const buffer = await this.helpers.getBinaryDataBuffer(0, 'data'); // (itemIndex, propertyName)
const text = buffer.toString('utf-8');
const length = buffer.length;
return [{
json: { ...$json, length },
binary: $input.item.binary, // pass the binary through, or it's gone
}];
Write by building the slot yourself — base64 the bytes plus a mime type and file name:
const text = 'Hello, world!';
return [{
json: { ok: true },
binary: {
report: {
data: Buffer.from(text).toString('base64'),
Questions fréquentes
Pourquoi le contenu de mon fichier est-il vide ?
Le contenu des fichiers est conservé dans la partie binaire de chaque élément, et non dans les champs de données habituels. Vérifier ces champs ne montre donc rien.
Un outil d'IA peut-il recevoir un fichier directement ?
Non. Les entrées et sorties des outils ne peuvent être que des données simples. Le fichier doit donc être stocké et transmis sous forme de lien ou de clé.
Comment les applications de discussion affichent-elles les images ?
Les outils de discussion comme Slack ou Telegram ont besoin d'un lien vers l'image, et non des données brutes du fichier.
Détails
Description originale de l’auteur
Handle files and binary data in n8n correctly. Use when working with files, images, PDFs, attachments, uploads or downloads, base64, vision/multimodal input, or when an AI agent needs a file as tool input or output — and whenever the user mentions $binary, binaryPropertyName, "read the PDF", "attach the file", "send the image", Merge losing binary, or a CDN for chat images. Covers the $binary vs $json split, reading/writing binary, keeping binary alive across transforms with Merge, the agent-tool binary boundary, and the CDN/URL requirement for chat surfaces.
repo: czlonkowski/n8n-mcp
Popularité
- Étoiles GitHub
- 23k
- Position au classement
- #10126
- Licence
- MIT
- Mis à jour
- 02/11/2026
Commentaires
- …
Autres skills de ce dépôt
n8n-agents
23kApprend à votre agent à bien concevoir des agents IA n8n, avec le bon modèle, les bons outils, la mémoire et le bon format de sortie.
n8n-code-tool
23kApprend à votre agent à écrire du JavaScript ou du Python pour un Custom Code Tool de n8n, que l'agent IA peut appeler.
n8n-error-handling
23kApprend à votre agent à configurer les workflows n8n pour que les échecs soient clairs, structurés et récupérables, au lieu de passer inaperçus.
n8n-multi-instance
23kAide votre agent à travailler en sécurité sur plusieurs instances n8n, comme la production et la préproduction, sans modifier la mauvaise.
Skills similaires
knowledge-automation
394kAide votre agent à configurer une tâche récurrente qui ajoute du nouveau contenu à votre coffre Knowledge selon un calendrier, puis vérifie qu'elle fonctionne.
knowledge-source-ingest
394kAide votre agent à tenir un coffre Knowledge à jour avec les nouveaux éléments de canaux de discussion, de flux ou de boîtes mail, sans rajouter ce qui existe déjà.
benchmark
280kAide votre agent à mesurer la vitesse et les performances du code. Utile pour s'assurer que tout est rapide et repérer les lenteurs.