n8n-binary-and-data
O que ela faz
Explica como o n8n guarda o conteúdo de arquivos separadamente dos dados comuns, e como ler, passar e enviar arquivos corretamente. Ela é indicada para quem constrói automações do n8n que trabalham com anexos ou uploads.
Quando usar
- ✓Quando um fluxo do n8n baixa um arquivo e a etapa seguinte não consegue encontrar o conteúdo dele.
- ✓Quando você quer que um agente de IA leia um PDF ou examine uma imagem.
- ✓Quando uma etapa de Merge parece descartar um anexo.
Link da skill
https://github.com/czlonkowski/n8n-mcp/blob/main/data/skills/n8n-binary-and-data/SKILL.mdCopie e cole na sua IA (Claude, ChatGPT ou Cursor) pedindo para seguir as instruções.
Como usar
O jeito mais fácil: copie a mensagem e cole na sua IA. Ela lê a skill e segue as instruções.
Mensagem pronta para colar
Para Claude Code, Codex ou Cursor: rode na pasta do projeto e a skill fica instalada.
Baixe o SKILL.md e coloque na pasta de skills do seu agente.
Exemplo do que pedir para a IA
“Meu fluxo do n8n perde o PDF anexado depois da etapa de merge. Corrija.”
5 skills novas por semana. 1 minuto de leitura.
Como funciona
A skill explica onde os dados do arquivo ficam em cada item do fluxo e mostra como lê-los, mantê-los e enviá-los, inclusive passando arquivos por link quando um chat ou ferramenta de IA precisa.
Conteúdo técnico (SKILL.md original)
Texto original do autor, em inglês, direto do 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'),
Perguntas frequentes
Por que o conteúdo do meu arquivo está vazio?
O conteúdo dos arquivos fica na parte binária de cada item, e não nos campos de dados comuns, então verificar os campos comuns não mostra nada.
Uma ferramenta de IA pode receber um arquivo diretamente?
Não. As entradas e saídas das ferramentas de IA só podem ser dados simples, então o arquivo precisa ser guardado e passado como link ou chave.
Como apps de chat mostram imagens?
Ferramentas de chat como Slack ou Telegram precisam de um link de imagem, e não dos dados brutos do arquivo.
Detalhes
Descrição original do 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
Popularidade
- Estrelas no GitHub
- 23 mil
- Posição no ranking
- #10126
- Licença
- MIT
- Atualizada em
- 02/11/2026
Comentários
- …
Mais skills deste repositório
n8n-agents
23 milEnsina seu agente a desenhar bem agentes de IA no n8n, com o modelo, as ferramentas, a memória e o formato de saída adequados.
n8n-code-tool
23 milEnsina seu agente a escrever JavaScript ou Python para uma Custom Code Tool do n8n que um agente de IA pode chamar.
n8n-error-handling
23 milEnsina seu agente a configurar fluxos do n8n para que as falhas sejam claras, estruturadas e recuperáveis, em vez de silenciosas.
n8n-multi-instance
23 milAjuda seu agente a trabalhar com segurança em várias instâncias do n8n, como produção e homologação, sem alterar a instância errada.
Skills parecidas
knowledge-automation
394 milAjuda seu agente a configurar uma tarefa recorrente que traz conteúdo novo para o seu Knowledge vault em uma agenda e a verificar se ela roda.
knowledge-source-ingest
394 milAjuda seu agente a manter o Knowledge vault atualizado com itens novos de canais de chat, feeds ou caixas de e-mail, sem adicionar de novo o que já existe.
benchmark
280 milAjuda seu agente a medir a velocidade e a performance do código. É útil para garantir que as coisas estão rápidas e para encontrar problemas de lentidão.