Loading...
Loading...
Use when handling files, images, attachments, or binary data in n8n, OR when an AI agent needs to take a user-uploaded file as tool input or return a generated file. For Data Tables (schemas, dedup, persistent state), see the separate n8n-data-tables skill. Triggers on "file", "image", "PDF", "attachment", "binary", "upload", "download", chat trigger with files, agent tool that needs a file, vision/multimodal, or any handling of non-JSON file data.
npx skill4agent add n8n-io/skills n8n-binary-and-data$json$binaryn8n-data-tables$binary$json$jsonfromAi()passthroughBinaryImages: truereferences/AGENT_TOOL_BINARY.mdreferences/MERGE_FOR_CONTEXT.md{
json: { ... }, // your data
binary: { // your files
data: { // 'data' is the typical key; can be any name
data: '<base64>',
mimeType: 'application/pdf',
fileName: 'invoice.pdf',
fileExtension: 'pdf',
},
},
}$binary.<key>binaryPropertyName$binary$binaryreturn [{
json: { ... },
binary: {
data: {
data: Buffer.from(content).toString('base64'),
mimeType: 'text/plain',
fileName: 'output.txt',
},
},
}]// In a Code node
const buffer = await this.helpers.getBinaryDataBuffer(0, 'data')
const text = buffer.toString('utf-8')references/BINARY_BASICS.mdfiles[]passthroughBinaryImages: truefromAi()fileNamefromAi('imageName', '...', 'string'){ ok: true, file_id: '...', url: '...' }references/AGENT_TOOL_BINARY.md[Source with binary] ─┬─→ [Edit Fields: transform JSON] ─┐
│ ├─→ [Merge: by position] ─→ [Email with attachment]
└─────────────────────────────────────┘references/MERGE_FOR_CONTEXT.md$binaryreferences/CDN_REQUIREMENT.mdn8n-data-tables| File | Read when |
|---|---|
| First time handling binary, or reading/writing the |
| Agent tool needs a user-uploaded file, or produces a file (the boundary in either direction) |
| Binary disappears after a JSON transform and needs to re-attach |
| Showing images in chat hub or other places that need URL-referenced images |
| Anti-pattern | What goes wrong | Fix |
|---|---|---|
Trying to read file content from | Binary isn't in | Use |
| Building an agent tool that returns binary directly | Tool output is JSON-only, so binary doesn't survive | Upload to storage, return key/URL in JSON (see |
Trying to pass uploaded chat files into a tool via | | Pre-stage uploads to storage, inject keys in the system prompt, and have the tool download by key |
Setting | The flag only affects what the LLM sees, not what tools receive | Still need the upload-and-pass-key pattern for tools |
| Losing binary after a JSON transform | The transform's output item doesn't have binary | Use Merge to combine the JSON output with the binary stream |
| Storing image in n8n binary and expecting chat hub to display | Chat hub needs URL-accessible images, not raw binary | Upload to CDN, embed URL in response |
| Hardcoding binary base64 in a Code node | Massive workflow JSON, slow, leaky | Reference binary via |