
An IPFS CID (content identifier) is the address IPFS gives content, built from a cryptographic hash of its root block. A few prefix bytes also name the hash function, the data format and the CID version, so any node can hash what it fetched and check it against the CID.
TL;DR:
Qm, always base58btc, dag-pb and sha2-256, and it is only the multihash0x01 for the version, 0x70 for dag-pb) and keeps the same digest; Kubo does it with ipfs cid format -v 1 -b base32cid field from every pin call, its upload options take a cid_version, and you can pin an existing CID with pinByHashUpdated Nov 30, 2026: trimmed sections that answer other queries, removed a docs-gap list, added a common-mistakes list, moved sources onto links.
A content identifier is a label that points to material in IPFS without saying where it is stored. It is a content address: the identifier comes from the content itself, so any difference in the content produces a different CID.
That gives you a check that a location address can't. When you fetch /ipfs/<CID> from any peer or gateway, you can hash what came back and compare. The same content added with the same settings on two nodes produces the same CID, which is why many unrelated nodes can serve one file.
A CID stays short no matter how large the content is, and the 2.59 GiB Ubuntu image in the IPFS docs example still gets a 46-character CIDv0.
CIDs are also how IPFS blocks point at each other. A file's root block lists its chunks by CID, and that chain of hashes is the Merkle DAG behind how IPFS works.
A CIDv1 string decodes into four fields, and each one answers a question a reader of the data would otherwise have to guess:
b means base32, the default for CIDv1, while z is base58btc, k base36 and f hex; the prefix only exists in the text form, not in the binary CID.0x01 for CIDv1.dag-pb (0x70, used by UnixFS files and folders), raw (0x55, plain bytes), dag-cbor (0x71) and dag-json (0x0129).0x12 for sha2-256), the digest length (0x20, which is 32 bytes), then the digest itself.Each code comes from the shared multiformats tables, so this post sticks to how the codes sit inside one CID.

We decoded the IPFS docs' example CID, bafybeigdyrzt5sfp7udm7hu76uh7y26nf3efuylqabf3oclgtqy55fbzdi, with a few lines of Python and a plain base32 decoder, so you don't need an IPFS node for this. Dropping the b and decoding the rest gives 36 bytes:
b multibase prefix: base32 (text form only)
01 CID version 1
70 multicodec: dag-pb
12 multihash function: sha2-256
20 digest length: 32 bytes
c3c4733ec8affd06cf9e9ff50ffc6bcd2ec85a6170004bb709669c31de94391a
the sha2-256 digest of the root blockNotice that every CIDv1 for dag-pb and sha2-256 starts with the same four bytes. That is why so many CIDs you see begin with bafybei while raw-codec CIDs begin with bafkrei, and the prefix tells you the format before you fetch anything.
Kubo prints the same fields with `ipfs cid format`, using codes such as %c for the codec name and %h for the multihash name, and ipfs cid inspect gives a readable breakdown.
The CID Inspector at cid.ipfs.tech runs the same decode in your browser. We pasted the docs' example CID into it on Nov 23, 2026, and this is the output, trimmed to the main fields:
HUMAN READABLE CID
base32 - cidv1 - dag-pb - (sha2-256 : 256 : C3C4733EC8AFFD06CF9E9FF50FFC6BCD2EC85A6170004BB709669C31DE94391A)
MULTIBASE PREFIX: b NAME: base32
MULTICODEC CODE: 0x70 NAME: dag-pb
MULTIHASH CODE: 0x12 NAME: sha2-256 BITS: 256
CID BYTE LENGTH
As base32 string (bytes): 59
Binary (bytes): 36Every field matches our hand decode above, including the digest and the 36-byte binary length. The string is 59 characters because base32 spends 8 characters on every 5 bytes, plus the one-character b prefix.
The first line is the human-readable form from the CID spec: multibase, version, codec and multihash names in a row. Those names are labels for people, and only the numeric codes are stable.
CIDv0 was the first design: a base58btc-encoded multihash and nothing else, 46 characters that start with Qm. Its codec is always dag-pb and its hash is always sha2-256, because the string has no room to say otherwise.
Our decode shows how close the two versions are. The CIDv0 of the same content, QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR, decodes to 34 bytes, and those bytes match the CIDv1 exactly once you drop its 01 70 header.
Decoders tell the two apart with a strict rule from the CID spec. A 46-character string that starts with Qm is a CIDv0 decoded as base58btc, and any other string is decoded by its multibase prefix. In binary, exactly 34 bytes starting 0x12 0x20 is a CIDv0, a leading 0x01 marks a CIDv1, and anything else is not a CID.
The version you get by default depends on the tool. Kubo's `Import.CidVersion` defaults to 0, so a plain ipfs add still returns a Qm CID, while ipfs add --cid-version 1 returns a CIDv1. For new projects, use CIDv1, because it names its codec and its base32 form survives case-insensitive systems such as DNS.
Kubo converts between versions with ipfs cid format. These are the IPFS docs' own examples; this machine has no IPFS binary, so we did not run them:
$ ipfs cid format -v 1 -b base32 QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR
bafybeigdyrzt5sfp7udm7hu76uh7y26nf3efuylqabf3oclgtqy55fbzdi
$ ipfs cid format -v 0 bafybeigdyrzt5sfp7udm7hu76uh7y26nf3efuylqabf3oclgtqy55fbzdi
QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnROur standard-library Python decode reproduces the same pair in both directions. In JavaScript, the toV1 and toV0 methods of a CID object in the multiformats library do the same.
The trip back to v0 only works for dag-pb. A CIDv1 with the raw, dag-cbor or dag-json codec can't become a CIDv0, because v0 has no codec field to record the change.
Usually not. In the Ubuntu ISO example from the IPFS docs, the SHA-256 checksum Ubuntu publishes starts b45165ed, while the digest inside the file's CID starts 0E7071C5, and running shasum --check with it fails.
The CID hashes the root block of the file's DAG, not the file's bytes. IPFS splits a large file into chunks, links them into a tree and wraps them in a codec, so the root block holds links rather than your data. The one exception is a single-block file stored with the raw codec, where the digest is a plain hash of the file.
A CID depends on the bytes and on how the importer turned them into blocks: chunk size, DAG layout, codec, CID version and hash function all change it. You can see two of them with a file as small as the 11 bytes hello world, with no trailing newline.
We imported those bytes three ways with ipfs-unixfs-importer 17.1.1, the importer that Helia's UnixFS package builds on, run here with Bun on Nov 23, 2026:
CIDv1, raw leaves bafkreifzjut3te2nhyekklss27nh3k72ysco7y32koao5eei66wof36n5e
CIDv1, no raw leaves bafybeihykld7uyxzogax6vgyvag42y7464eywpf55gxi5qpoisibh3c5wa
CIDv0, no raw leaves Qmf412jQZiuVUtdgnB36FXFX7xg5V6KEbSJ4dpQuhkLyfDThe first CID uses the raw codec, so its digest is the plain SHA-256 of hello world, the one case where a CID matches a file checksum. It is also the IPIP-0499 reference CID for these bytes. The other two wrap the same bytes in a dag-pb UnixFS node, which changes the hashed block, so the digest changes too. Those two share one digest and differ only in version and encoding, which is why one converts to the other.
Bigger files add chunking and layout, and the two IPIP-0499 import profiles fix those settings so that two tools can agree on a CID.
Most CID bugs come from treating a CID as something it is not. Four mistakes come up again and again:
hello world one above, carries the file's own hash. A dag-pb CID hashes a UnixFS node, so the check fails even for the right file.0x70, not the text dag-pb, because only the numeric codes are stable.The takeaway: a CID is a self-describing hash, so you can read its four fields and check it against bytes you hashed yourself, whoever stores the file. Every pinning response in the AIOZ Pin Pinning API includes a cid field, and the upload options object takes a cid_version, which the docs example sets to 1. If the file is already on IPFS, you can pin it by its CID instead. This is the CLI example from the AIOZ Pin SDK page, not run here:
pinning pin --hash QmdYTBNig2d4dQd5o1LXM3NHbCYA7168NpN5R9m44vDj88 --keyvalue key1:value1The decode from this post applies straight away: the docs' example hash is 46 characters and starts with Qm, so it is a CIDv0, and its 34 bytes start 12 20 for a sha2-256 digest of a dag-pb block. If you need a CID you can reproduce locally, compare the returned cid with your own import of the same file, because import settings change the CID.
What does CID stand for? Content identifier, the self-describing hash-based address IPFS uses for every block of content.
Why do some CIDs start with Qm and others with bafy? Qm marks a CIDv0 in base58btc, while bafy marks a base32 CIDv1 for dag-pb and sha2-256, because those first bytes are the same for every such CID.
Can every CIDv1 be converted to CIDv0? No. Only dag-pb CIDs can go back to v0, while raw, dag-cbor and dag-json CIDs return an error.
Does the same file always get the same CID? Only with the same settings, because chunk size, DAG layout, codec, CID version and hash function all change the result.
Can two different files share a CID? Only through a hash collision, and with sha2-256 finding one is computationally infeasible.

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.