n8n-binary-and-data
Qué hace
Explica cómo n8n guarda el contenido de los archivos aparte de los datos normales, y cómo leer, pasar y enviar archivos correctamente. Es para personas que crean automatizaciones en n8n que trabajan con adjuntos o subidas.
Cuándo usarla
- ✓Cuando un flujo de n8n descarga un archivo y el paso siguiente no encuentra su contenido.
- ✓Cuando quieres que un agente de IA lea un PDF o mire una imagen.
- ✓Cuando un paso Merge parece perder un archivo adjunto.
Link de la skill
https://github.com/czlonkowski/n8n-mcp/blob/main/data/skills/n8n-binary-and-data/SKILL.mdCópialo y pégalo en tu IA (Claude, ChatGPT o Cursor) pidiéndole que siga las instrucciones.
Cómo usar
La forma más fácil: copia el mensaje y pégalo en tu IA. Ella lee la skill y sigue las instrucciones.
Mensaje listo para pegar
Para Claude Code, Codex o Cursor: ejecútalo en la carpeta del proyecto y la skill queda instalada.
Descarga el SKILL.md y ponlo en la carpeta de skills de tu agente.
Ejemplo de qué pedirle a la IA
“Mi flujo de n8n pierde el PDF adjunto después del paso Merge. Arréglalo.”
5 skills nuevas por semana. 1 minuto de lectura.
Cómo funciona
La skill explica dónde está el dato del archivo en cada elemento del flujo y muestra cómo leerlo, conservarlo y enviarlo, incluido el paso de pasarlo como enlace cuando un chat o una herramienta de IA lo necesita.
Contenido técnico (SKILL.md original)
Texto original del autor, en inglés, directo de 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'),
Preguntas frecuentes
¿Por qué está vacío el contenido de mi archivo?
El contenido de los archivos se guarda en la parte binaria de cada elemento, no en los campos de datos normales, así que revisar los campos normales no muestra nada.
¿Puede una herramienta de IA recibir un archivo directamente?
No. Las entradas y salidas de las herramientas solo pueden ser datos simples, así que el archivo debe guardarse y pasarse como enlace o clave.
¿Cómo muestran las imágenes las aplicaciones de chat?
Herramientas como Slack o Telegram necesitan un enlace a la imagen, no los datos del archivo en bruto.
Detalles
Descripción original del autor
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
Popularidad
- Estrellas en GitHub
- 23 mil
- Posición en el ranking
- #10126
- Licencia
- MIT
- Actualizada
- 2/11/2026
Comentarios
- …
Más skills de este repositorio
n8n-agents
23 milEnseña a tu agente a diseñar bien agentes de IA en n8n, con el modelo, las herramientas, la memoria y el formato de salida adecuados.
n8n-code-tool
23 milEnseña a tu agente a escribir JavaScript o Python para una Custom Code Tool de n8n que un agente de IA pueda llamar.
n8n-error-handling
23 milEnseña a tu agente a configurar los flujos de n8n para que los fallos sean claros, estructurados y recuperables, en lugar de silenciosos.
n8n-multi-instance
23 milAyuda a tu agente a trabajar con seguridad en varias instancias de n8n, como producción y pruebas, sin modificar la equivocada.
Skills parecidas
knowledge-automation
394 milAyuda a tu agente a configurar una tarea recurrente que añade contenido nuevo a tu bóveda de Knowledge según un horario, y después comprueba que la tarea funciona.
knowledge-source-ingest
394 milAyuda a tu agente a mantener al día una bóveda de Knowledge con elementos nuevos de canales de chat, fuentes o buzones, sin volver a añadir lo que ya tiene.
benchmark
280 milAyuda a tu agente a medir la velocidad y el rendimiento del código. Es útil para asegurar que todo vaya rápido y encontrar problemas de lentitud.