Langsung ke konten
Skillpedia
Otomatisasi23k Β· #10126

n8n-binary-and-data

Fungsinya

Skill ini menjelaskan cara n8n menyimpan isi file secara terpisah dari data biasa, serta cara membaca, meneruskan, dan mengirim file dengan benar. Cocok untuk orang yang membangun otomatisasi n8n yang memakai lampiran atau unggahan.

Kapan dipakai

  • βœ“Saat alur kerja n8n mengunduh file dan langkah berikutnya tidak bisa menemukan isinya.
  • βœ“Saat Anda ingin agent AI membaca PDF atau melihat gambar.
  • βœ“Saat langkah Merge tampaknya menghilangkan lampiran file.

Link skill

https://github.com/czlonkowski/n8n-mcp/blob/main/data/skills/n8n-binary-and-data/SKILL.md

Salin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.

Cara pakai

Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.

Pesan siap tempel

Gunakan skill ini untuk membantu saya: https://github.com/czlonkowski/n8n-mcp/blob/main/data/skills/n8n-binary-and-data/SKILL.md Baca file SKILL.md di link tersebut dan ikuti instruksinya untuk tugas saya.
Mau AI Anda menemukan skill seperti ini sendiri?Pasang MCP Skillpedia gratis: cukup satu baris, dan AI mencari di antara 15.000+ skill sebelum tiap tugas.Pasang dalam 1 menit β†’

Contoh permintaan ke AI

β€œLampiran PDF di alur kerja n8n saya hilang setelah langkah merge. Perbaiki.”

5 skill baru setiap minggu. 1 menit baca.

Cara kerjanya

Skill menjelaskan di mana data file berada pada setiap item alur kerja, lalu menunjukkan cara membaca, menyimpan, dan mengirimnya, termasuk meneruskan file melalui tautan ketika chat atau alat AI membutuhkannya.

Konten teknis (SKILL.md asli)

Teks asli dari pembuat, dalam bahasa Inggris, langsung dari 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

  1. 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>. $json holds metadata at most. Reading $json.data for file contents gives you nothing.

  2. 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.

  3. 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. See CDN_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'),
    
Pertanyaan umum

Mengapa isi file saya kosong?

Isi file disimpan di bagian biner setiap item, bukan di kolom data biasa, sehingga memeriksa kolom biasa tidak menampilkan apa pun.

Bisakah alat AI langsung menerima file?

Tidak. Input dan output alat hanya bisa berupa data biasa, sehingga file harus disimpan dan diteruskan sebagai tautan atau kunci.

Bagaimana aplikasi chat menampilkan gambar?

Alat chat seperti Slack atau Telegram memerlukan tautan gambar, bukan data file mentah.

Detail

Deskripsi asli dari pembuat

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

Popularitas

Bintang GitHub
23k
Peringkat
#10126
Lisensi
MIT
Diperbarui
2/11/2026

Apakah skill ini berguna?

0

Masuk untuk memberi suara.

Komentar

  • …

Skill lain dari repositori ini

Skill serupa