Back

Blog details

What Are Multiformats? Multihash, Multibase and Multicodec

AIOZ Network
6 min readNovember 18, 2026
aioz-pin
AIOZ Pin cover image reading What Are Multiformats?

Multiformats are self-describing value formats: each value carries a short prefix that says which hash function, text encoding or data format produced it. IPFS builds every CID you see from three of them, multihash, multibase and multicodec.

TL;DR:

  • A multihash is a hash code, a digest length and the digest, so 12 20 in front of 32 bytes means sha2-256
  • A multibase prefix is one character in front of text: b is base32, z is base58btc, f is hex
  • Multicodec is one shared table of binary codes, tagged by use: hashes, keys, network protocols and data codecs
  • Codes are unsigned varints, so a code under 128 costs one byte and dag-json (0x0129) costs two
  • Every CID the AIOZ Pin API returns decodes with standard multiformats tools

What are multiformats?

Multiformats are protocols that make a value describe itself, so a system can switch hash functions or encodings later without breaking stored data. The project marks four registries as stable: multiaddr, multibase, multicodec and multihash. Together they sit under how IPFS addresses and links data.

Say you receive 32 bytes of hex. SHA-256 and SHA3-256 both produce 32 bytes, so the length can't tell you which function to rerun when you verify the data, while a prefix's first byte names it.

You meet multiformats every time you read a CID, as the diagram below shows. For a byte-by-byte walk through a dag-pb CID and CIDv0 to CIDv1 conversion, see our anatomy of an IPFS CID.

Labelled diagram of the CIDv1 for the bytes hello world: the b prefix is multibase (base32), 01 is the version, 55 is the multicodec for raw, and 12 20 plus the digest is the multihash (sha2-256, 32 bytes). Below, the multibase table with b, z, f, k and m, and the multicodec table with 653 codes: multihash 359, key 89, multiaddr 46, ipld 45

What is a multihash?

A multihash is a hash digest with two prefixes in front: a varint code for the hash function and a varint for the digest length in bytes. You can check this with any hash library, and we used Python's hashlib on the 11 bytes hello world.

SHA-256 gives a digest starting b94d27b9, so the multihash is 1220 plus that digest. SHA3-256 gives a different 32-byte digest, and its multihash starts 1620 because SHA3-256 is code 0x16. The length is the same, so only the code tells the two apart.

The length gets its own field so that a custom digest size doesn't need a new code. Non-cryptographic hashes carry the tag hash instead, like murmur3-x64-64, which IPFS uses to shard large directories.

Code 0x00 is the identity multihash, which stores the bytes themselves instead of a digest. The libp2p spec uses it for peer IDs whose public key fits in 42 bytes, and our glossary entry for multihash lists the terms around it.

What is multibase?

Multibase is a one-character prefix that says which base encoding turned binary data into text. The README's example is the string 1214314321432165, where you can't tell whether it is decimal or hex until a prefix says so.

PrefixEncodingStatus in multibase.csv
bbase32, lowercase, no paddingfinal
zbase58btcfinal
fbase16 (hex), lowercasefinal
kbase36draft
mbase64, no paddingfinal

Each prefix letter belongs to its encoding's alphabet, so hex gets f. Q and 1 are reserved because base58 multihashes already start with them (CIDv0 strings and libp2p peer IDs), and / is kept for multiaddrs.

Multibase exists only in text, since a binary CID carries no base prefix, so you can write one CID in any base. Here is our hello world CID four ways, encoded with a stdlib script:

bafkreifzjut3te2nhyekklss27nh3k72ysco7y32koao5eei66wof36n5e        base32 (b)
zb2rhj7crUKTQYRGCRATFaQ6YFLTde2YzdqbbhAASkL9uRDXn                  base58btc (z)
k2cwued9o1pvrt3q271rrqbo49x30tbxwpoeaq75z14e5ui2rzygpbe1           base36 (k)
f01551220b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9   base16 (f)

Multicodec: one table for every binary code

Multicodec is the shared table of binary codes the other formats draw from. On Oct 29, 2026, table.csv had 653 rows, which we counted with Python's csv module: multihash 359, key 89, multiaddr 46 and ipld 45 were the biggest tags. Our glossary entry for multicodec gives the short version.

The tag tells you where a code belongs. A CID's codec slot takes an ipld code such as raw (0x55), dag-pb (0x70) or dag-cbor (0x71), and IPLD defines what those codecs decode to. A multiaddr takes tcp (0x06) and p2p (0x01a5) from the same table.

Most rows are drafts (587 of 653), and codes are handed out first come, first served through a pull request. Codes under 128 fit in one byte, so the README suggests newcomers ask for a code above 0x80, and the range 0x300000 to 0x3FFFFF is free for private use.

Every code is an unsigned varint: seven bits per byte, low bits first, with the top bit saying another byte follows. You always get the shortest form, so 0x55 is the single byte 55 while dag-json (0x0129) becomes a9 02.

Build a CID from the three prefixes

You don't need an IPFS node to see the three formats work together. This stdlib Python builds the raw-codec CIDv1 for hello world, and we ran it with Python 3.12 on Oct 29, 2026:

import base64, hashlib

def varint(n):
    out = bytearray()
    while True:
        low, n = n & 0x7F, n >> 7
        out.append(low | 0x80 if n else low)
        if not n:
            return bytes(out)

digest = hashlib.sha256(b"hello world").digest()
multihash = varint(0x12) + varint(len(digest)) + digest  # sha2-256, 32 bytes
cid = varint(1) + varint(0x55) + multihash  # CIDv1, raw codec
print(multihash[:2].hex(), varint(0x0129).hex())
print("b" + base64.b32encode(cid).decode().lower().rstrip("="))

It printed 1220 a902 and then the bafkrei... string shown above. The digest inside matches what sha256sum prints for the same 11 bytes, because a single raw block is hashed as is. Larger files are chunked into a DAG first, which is why one file can end up with different CIDs.

Kubo has a command for each table, quoted here from its CLI reference (Kubo 0.43.1) and not run, since we have no IPFS binary:

ipfs cid bases --prefix      # multibase prefixes
ipfs cid codecs --numeric    # CID multicodecs with codes
ipfs cid hashes --numeric    # multihash functions with codes
ipfs cid inspect <cid>       # all parts of one CID
echo hello | ipfs multibase encode -b base16
f68656c6c6f0a               # documented output: f prefix, then hex

Where the multiformats specs live

Multiformats are not an IETF standard yet. The multihash Internet-Draft expired after revision 07 in August 2023, and Datatracker lists the proposed Multiformats working group as "Abandoned", so treat the GitHub tables, table.csv and multibase.csv, as the source of truth.

How AIOZ Pin handles it

AIOZ Pin works with standard CIDs. An upload with POST https://api.aiozpin.network/api/pinning returns a data object with a cid field, and to pin an existing CID you send it as hash_to_pin. This body is the docs' own example, quoted, not run:

POST https://api.aiozpin.network/api/pinning/pinByHash
{"hash_to_pin": "Qmc1135ziMvmFG534i75E8HpJoLqzLzgKBxfjBV9cBsMAs", "metadata": {"name": "name-ipfs-hash"}}

That CID is a CIDv0, so its base (base58btc) and codec (dag-pb) are implicit, and its 34 bytes are just a multihash starting 12 20. Our stdlib script converts it to the CIDv1 bafybeigk7l6cb7e54herg5u5evg6227dtijmeg5qakdfjtmdq5225vrslq, which names the same content. The image optimization guide's example, bafkreiefnp4d..., is a CIDv1 that decodes to 01 55 12 20: raw codec, sha2-256.

What the docs don't cover yet: which CID version an upload returns, and how the response's root_hash differs from cid. For the fields, see the AIOZ Pin Pinning API docs.

Frequently Asked Questions

Are multiformats only used by IPFS?
No. libp2p and IPLD build on them, and the proposed IETF charter lists W3C credential and identifier groups as users.

Is a multihash the same as a CID?
No. A CIDv1 adds a version and a multicodec in front of the multihash, while a CIDv0 is a bare multihash that can't name its codec.

Why do so many multihashes start with the same bytes?
The first bytes are the function code and length, so every sha2-256 multihash starts 12 20; skip them when you need random-looking input, as in a Bloom filter.

Can I add my own code to the multicodec table?
Yes. Open a pull request with a unique name, code, tag and the status "draft", or use the private range for internal formats.

Which multibase should I use for CIDs?
Use base32 (b), the IPFS default for CIDv1, because DNS names ignore case; the IPFS docs suggest base36 (k) for long keys such as IPNS names.

References

We only send updates when meaningful changes ship, and you can unsubscribe anytime

Related Content

blog thumbnail

ENS IPFS Contenthash: Point an .eth Name at a Website

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.

7 min readDecember 04, 2026
blog thumbnail

ERC-721 Metadata JSON: Fields, Images and ipfs:// URIs

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

8 min readDecember 02, 2026
blog thumbnail

Merkle DAG vs Merkle Tree: What IPFS Changes and Why

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.

8 min readNovember 30, 2026
blog thumbnail

What Is IPNI? How the IPFS Network Indexer Finds Providers

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

8 min readNovember 27, 2026
blog thumbnail

On-Chain vs Off-Chain NFT Metadata: Where the Data Lives

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.

6 min readNovember 25, 2026
blog thumbnail

What Is a Kademlia DHT? The Routing Algorithm Behind IPFS

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.

6 min readNovember 23, 2026