
To verify a CID yourself, download the file, recompute its CID from the bytes, and compare it with the CID the NFT references. If they match, the file is exactly what was pinned. Below are the steps, a check we ran, and the settings that cause false alarms.
TL;DR:
ipfs add --only-hash computes a CID without storing or announcing anything, and it still defaults to CIDv0Updated Nov 4, 2026: fixed the claim that Kubo defaults to CIDv1, since its default is still CIDv0. We added a real verification run on an image CID from the AIOZ Pin docs, sections on import settings, CID profiles and trustless gateways, a labelled diagram, and a closing section on AIOZ Pin.
A CIDv1 has four parts. A multibase prefix says how the string is encoded, such as b for base32, followed by a version number. Then comes a multicodec that says how the data is structured, and a multihash that names the hash function and holds the digest.
None of these parts is assigned by the server that hosts your file. As the IPFS docs on CIDs put it, "any difference in the content will produce a different CID." Two people who add the same bytes with the same settings, on different machines, get the same CID, byte for byte.
There's one catch you should know before you start. A CID is usually not a plain hash of your file. IPFS splits larger files into chunks, links them into a Merkle DAG, and hashes the root block of that DAG. That is why the SHA-256 checksum a project publishes for a download rarely appears inside its CID. To see how the blocks fit together, read how IPFS turns files into a Merkle DAG.
The exception is a file small enough to fit in one block and stored with the raw codec. In that case the CID's digest is the SHA-256 of the file itself, and those CIDs start with bafkrei in base32.
The method is the same for every file, and it takes three steps:
ipfs://bafkrei....A match proves the bytes you hold are the bytes behind that CID. It doesn't matter which gateway served them, or whether you trust it.
We ran this on 2026-11-04 with a real example. The AIOZ Pin image optimization docs use the image CID bafkreiefnp4dflv35vsqzrnp25woubdbylgesttpanq6dfkctbhgo3lvy4. We downloaded it from the AIOZ Pin public gateway and recomputed its CID with Python's standard library, with no IPFS software installed:
import hashlib, base64, sys
def raw_cid(data: bytes) -> str:
# CIDv1 = version 0x01, raw codec 0x55, sha2-256 multihash 0x12 0x20, then the digest
prefix = bytes([0x01, 0x55, 0x12, 0x20])
digest = hashlib.sha256(data).digest()
return "b" + base64.b32encode(prefix + digest).decode().lower().rstrip("=")
expected = sys.argv[2]
data = open(sys.argv[1], "rb").read()
print("bytes: ", len(data))
print("computed:", raw_cid(data))
print("expected:", expected)
print("match: ", raw_cid(data) == expected)
This is the output we got, first for the downloaded file and then for a copy where we flipped one bit in the last byte:
$ curl -s -o docs-example.webp https://public.aiozpin.network/ipfs/bafkreiefnp4dflv35vsqzrnp25woubdbylgesttpanq6dfkctbhgo3lvy4
$ python3 verify_cid.py docs-example.webp bafkreiefnp4dflv35vsqzrnp25woubdbylgesttpanq6dfkctbhgo3lvy4
bytes: 82148
computed: bafkreiefnp4dflv35vsqzrnp25woubdbylgesttpanq6dfkctbhgo3lvy4
expected: bafkreiefnp4dflv35vsqzrnp25woubdbylgesttpanq6dfkctbhgo3lvy4
match: True
$ python3 verify_cid.py docs-example-1byte.webp bafkreiefnp4dflv35vsqzrnp25woubdbylgesttpanq6dfkctbhgo3lvy4
bytes: 82148
computed: bafkreig4gp2pde4yjydatuiicqijmhf2iyejmjnqa3w4u3xou4t2qgl7wy
expected: bafkreiefnp4dflv35vsqzrnp25woubdbylgesttpanq6dfkctbhgo3lvy4
match: False
One flipped bit gave a completely different CID. That is the whole tamper check, and it only works this simply because the image is a single raw block.

For anything bigger than one block, you need a tool that builds the same DAG the original uploader built. Kubo, the Go implementation of IPFS, has a flag for this: --only-hash, or -n. It runs the import and prints the CID, but it doesn't store the blocks or announce them to the network.
We have no IPFS binary on this machine, so these commands come from the Kubo CLI reference and were not run here:
# Not run: CIDv0, Kubo's default (Import.CidVersion = 0)
ipfs add --only-hash my-nft-metadata.json
# Not run: CIDv1, which also turns on raw leaves by default
ipfs add --only-hash --cid-version 1 my-nft-metadata.json
# Not run: a whole folder, which returns one root CID for the collection
ipfs add --only-hash -r ./collection
Kubo's config docs still list Import.CidVersion with a default of 0. So a plain ipfs add -n prints a CID that starts with Qm, and you have to ask for CIDv1 if the token URI uses one.
A mismatch doesn't prove tampering. Before you raise an alarm, rule out these differences in how the file was imported. Each one changes the DAG, and so the root CID, even when the bytes are identical:
ipfs cid format won't fix this, because the digests are already different.unixfs-v1-2025 profile uses 1 MiB.--wrap-with-directory, gets a root CID for the folder, not for the file.This used to be a real headache, because Kubo, Helia and other tools picked different defaults. IPIP-499 now names two CID profiles: unixfs-v0-2015 for legacy CIDv0 and unixfs-v1-2025 for new work. Per Kubo's docs, unixfs-v1-2025 means CIDv1, raw leaves, sha2-256, 1 MiB chunks and 1,024 links per file node. If you know which profile an upload used, you can apply it with ipfs config profile apply and recompute. Our post on why the same file used to get different CIDs covers the history.
Generative collections often pin a folder of metadata files and point every token at a path inside it, such as ipfs://<root CID>/42.json. The folder's root CID depends on every file in it, and on every file name, as our explainer on how UnixFS represents directories shows.
So if you rebuild the folder and get the same root CID, you have verified every file in the collection at once. If you only care about one token, you don't need the whole folder: fetch that one path from a verifying source, as the next section describes.
Recomputing a CID only works when you can match the original settings. There's a second way that avoids the problem completely: ask for the blocks instead of the finished file, and check each block against its own CID.
A trustless gateway does exactly that. Per the Trustless Gateway spec, you request ?format=raw for a single block or ?format=car for a CAR stream, and every block in the response can be checked against its CID. Your client then rebuilds the file from blocks it has verified, so the import settings no longer matter. Our posts on how IPFS verifies content without trusting the gateway and CAR files go deeper. In JavaScript, @helia/verified-fetch gives you a fetch-like API that does this checking for you.
You download most files once and move on. An NFT's metadata is a claim that lasts as long as the token, and buyers may judge a token by what that metadata says years later. A marketplace's cached preview can drift from the pinned file, and a CID check is how you find out.
A CID proves integrity, not availability. If nobody keeps the file pinned, the CID still identifies it but no one can serve it, which is the problem our post on what happens when an NFT's pin expires covers.
The AIOZ Pin docs describe the same property on their IPFS protocol page: any attempt to modify an NFT's content results in a different CID. Our check above used the AIOZ Pin public gateway, and you can verify anything it serves the same way, because the bytes either match the CID or they don't.
If you already know the CID of content you want to keep online, you don't need to upload the file again. The Pinning API pins an existing CID with hash_to_pin, and you can verify that CID before you pin it. One gap in the docs: they don't say which import settings or CID version AIOZ Pin uses when you upload a file, so compare CIDs from the API response rather than from a local re-import. Our guide to how AIOZ Pin works covers the pinning side.
Next step: see the AIOZ Pin Pinning API for pinning by CID and the response fields.
What determines an NFT's CID? The bytes of the file, plus the import settings: CID version, codec, hash function, chunk size and DAG layout. No server assigns it.
Can I verify a CID without re-uploading the file? Yes. Kubo's ipfs add --only-hash computes the CID locally without storing or announcing anything, and a single raw block can be checked with a plain SHA-256.
What does it mean if my recomputed CID doesn't match? Either the bytes differ, or you used different import settings. Check the CID version, raw leaves, chunk size and folder wrapping before you assume tampering.
Does changing one byte change the CID? Yes. In our test, flipping a single bit of an 82,148-byte image produced a completely different CID.
Why doesn't a file's SHA-256 checksum match its CID? For most files, the CID hashes the root block of a DAG built from chunks, not the file itself. Only a single raw block has a CID whose digest equals the file's SHA-256.
Is there a way to verify without matching import settings? Yes. Fetch the blocks from a trustless gateway as raw blocks or a CAR file, and check each block against its own CID.

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.