
UnixFS is the data format IPFS uses to represent files and directories. The raw Merkle DAG only knows hash-linked blocks of bytes. UnixFS adds filenames, folders, symlinks and file sizes on top, so a CID can stand for a whole file or folder.
TL;DR:
dag-pb codec, that adds file, directory and symlink meaning to DAG nodesDataType field has six values: Raw, Directory, File, Metadata, Symlink and HAMTShard, although the spec now marks Raw as deprecated and Metadata as reservedfilesize and blocksizes fieldsHAMTShard layout once they pass a size threshold (256 KiB in Kubo), with a fanout of 256Updated Nov 30, 2026: added importer runs on one 12-byte notes.txt, a common-mistakes list and in-sentence links; cut a docs-gap line and repeated FAQs.

The Merkle DAG that underlies all of IPFS is generic on purpose. It has nodes, links and hashes, and it makes no assumption about what the data inside a node means. That is why IPFS can carry many data formats on the same graph, not only files.
The cost of that generality is that the DAG can't answer the questions a filesystem needs. Is this node a file or a folder, what is it called, and how big is it? And if it is split across blocks, in what order do they go back together? UnixFS is the layer that answers them for you, every time you add a file or folder.
UnixFS is a protocol-buffers format for describing files, directories and symlinks on IPFS. Each UnixFS node is a dag-pb block whose Data field holds a small protobuf message. That message has a required Type field, plus optional fields for raw bytes, file size, block sizes and directory settings such as fanout.
To be precise, UnixFS is one way of reading the Merkle DAG, not a different storage system. The blocks and hashes are the same; a UnixFS-aware tool just knows how to read the extra structure. A tool that doesn't understand UnixFS can still fetch and verify every block, but it can't show you files and folders.
The DataType enum in the UnixFS spec lists six values. Here is what each one does today:
raw codec instead.myfolder/photo.png resolves by name.Day to day, you mostly meet File, Directory and HAMTShard nodes, plus raw leaf blocks if you add files with CIDv1. The spec also defines two optional fields from UnixFS 1.5, mode and mtime, for Unix permissions and modification times, and implementations only set them when you opt in.
Blocks have a practical size ceiling, so any big file you add has to be split. Kubo's default chunker cuts files into fixed 256 KiB pieces, and content-defined chunking is the alternative that picks cut points from the data itself.
The File node then links to those chunks, in order, and records two fields. filesize is the total length of the file, and blocksizes lists the size of each child. A UnixFS reader uses blocksizes to rebuild the file in the right order, whichever peers the blocks come from. The same list shows which blocks hold a byte range, so a reader can serve an HTTP Range request without fetching the whole file.
Very large files need more than one level, because Kubo caps a File node at 174 links by default, so beyond that it builds a tree of File nodes above the leaves. The leaves themselves are often not UnixFS nodes at all. With CIDv1, Kubo turns on raw leaves by default, so each chunk is stored as a plain raw block.
Take notes.txt from the diagram and give it the 12 bytes hello world\n. It fits in one chunk, so with raw leaves the whole file is one raw block, and Python's standard library can compute its CID. The recipe is the bytes 01 55 12 20 (CIDv1, raw codec, sha2-256, 32-byte length), then the SHA-256 digest, encoded as lowercase base32 with a b prefix:
# Run here with Python's standard library (no IPFS binary)
import hashlib, base64
data = b"hello world\n"
cid = bytes([0x01, 0x55, 0x12, 0x20]) + hashlib.sha256(data).digest()
print("b" + base64.b32encode(cid).decode().lower().rstrip("="))
# bafkreifjjcie6lypi6ny7amxnfftagclbuxndqonfipmb64f2km2devei4
The bafkrei prefix is typical of a CIDv1 raw block with a SHA-256 hash. Import the same notes.txt with Kubo's default settings (CIDv0, dag-pb leaves) and the bytes are wrapped in a UnixFS File node first, so the CID changes. We checked both, and a folder, with the ipfs-unixfs-importer library that Helia uses, run here with Bun on Nov 30, 2026:
import { importer } from 'ipfs-unixfs-importer'
import { MemoryBlockstore } from 'blockstore-core'
const bytes = s => new TextEncoder().encode(s)
async function add (files, opts) {
const out = []
for await (const e of importer(files, new MemoryBlockstore(), opts)) {
out.push(`${e.path || '(root)'} ${e.cid}`)
}
return out.join('\n')
}
// Kubo's defaults: CIDv0, dag-pb leaves
console.log(await add([{ path: 'notes.txt', content: bytes('hello world\n') }],
{ cidVersion: 0, rawLeaves: false }))
// CIDv1 with raw leaves
console.log(await add([{ path: 'notes.txt', content: bytes('hello world\n') }],
{ cidVersion: 1, rawLeaves: true }))
// notes.txt inside a folder, then one byte changed
for (const text of ['hello world\n', 'hello world!']) {
console.log(await add([{ path: 'docs/notes.txt', content: bytes(text) }],
{ cidVersion: 1, rawLeaves: true }))
}notes.txt QmT78zSuBmuS4z925WZfrqQ1qHaJ56DQaTfyMUF7F8ff5o
notes.txt bafkreifjjcie6lypi6ny7amxnfftagclbuxndqonfipmb64f2km2devei4
docs/notes.txt bafkreifjjcie6lypi6ny7amxnfftagclbuxndqonfipmb64f2km2devei4
docs bafybeia6c3p2byvm3xvcgnca26fbfcyscm2gd6irvdacxf35zacke5kmdu
docs/notes.txt bafkreidvbhs33ighmljlvr7zbv2ywwzcmp5adtf4kqvlly67cy56bdtmve
docs bafybeibqe4wdbb4c7pawu54ghinxdo24xtto3uz4ydufedirr4zef4yrjeThe first two lines are the same 12 bytes under two settings, which is why the same file can end up with different CIDs. The second matches the stdlib result above. The last four lines put notes.txt in a folder named docs, then change its final byte.
A plain Directory node stores its entries as one flat list of named links. That works until the folder is so big that the list itself becomes a huge block. Kubo switches a directory to sharding when its estimated size passes 256 KiB by default, and the spec gives 256 KiB to 1 MiB as the common range.
Past that point, the folder becomes a tree of HAMTShard nodes. The fanout field sets how many buckets each level has, and Kubo's default is 256, which uses 8 bits of the name's hash per level. For you, folder/file.txt still resolves the same way. Only the HAMT node structure behind it changes.
When you pin a folder's root CID recursively, you protect the whole UnixFS tree under it. That includes every File node, every chunk, every subdirectory and every HAMT shard, because each one is reachable by links from the root.
It also explains why changing one file in a folder changes the folder's CID. In the run above, turning the newline in notes.txt into ! keeps the file at 12 bytes, yet the docs folder moves from bafybeia6c3p... to bafybeibqe4w.... The file's CID changes, so the link in its parent changes, so every directory up to the root gets a new hash. A static website hosted on IPFS is exactly this: a build folder turned into a UnixFS tree, with one root CID per release. The IPFS Mutable File System (MFS) lets your node recompute those CIDs while you edit files by path.
notes.txt is QmT78zSu... as CIDv0 with dag-pb leaves and bafkreif... as CIDv1 with raw leaves. Match CID version, raw leaves and chunker before you call two copies different.The takeaway: one root CID names a whole UnixFS tree, and any change inside it produces a new root. AIOZ Pin gives you two ways to pin a whole folder: the Node.js SDK and the pinning CLI. In the quick start, client.pinFolderToIPFS takes the folder path as sourcePath, and the CLI pins a directory when you pass its path to --file.
From the AIOZ Pin quick start, not run here because it needs real keys:
// Not run: from the AIOZ Pin quick start (Node.js SDK)
client.pinFolderToIPFS({ sourcePath: './folder', options }).then((result) => {
console.log(result);
}).catch((err) => {
console.log(err);
});
The pin records in the Pinning API include an is_dir flag, so you can tell a folder pin from a file pin when you list your pins. Next step: follow the AIOZ Pin quick start to pin your first folder.
What is UnixFS in IPFS? It is the format IPFS uses for files and directories. It adds file, directory and symlink meaning on top of the Merkle DAG, which has none of its own.
What chunk size does IPFS use? Kubo's default chunker is size-262144, which is 256 KiB per chunk. You can change it per add or in the config.

An ENS IPFS contenthash points your .eth name at a site on IPFS. See the byte format, a real encoding, ipfs vs ipns records, gas used, and common mistakes.

ERC-721 metadata JSON explained: the three fields EIP-721 defines, OpenSea attributes and animation_url, ipfs:// image links, and folder CIDs for collections.

Merkle DAG vs Merkle tree explained: a tree gives each node one parent and short proofs, while the DAG IPFS uses shares blocks, carries data and links by CID.

IPNI is the IPFS network indexer behind cid.contact. See how index providers publish signed advertisement chains and how one HTTP query finds providers.

On-chain vs off-chain NFT metadata: what the contract stores, what lives on IPFS or a web server, what each costs in gas, and how to check any token yourself.

A Kademlia DHT finds peers by XOR distance. See how k-buckets, k = 20 and iterative lookups let IPFS locate who holds a CID, and how to watch it on Kubo.