# Cid version convert

`cid-version-convert` · version 1.0.0 · Encoding & checksums · free, no key needed

Convert permitted CIDv0 and CIDv1 envelopes without recomputing their multihash.

**Use when you need to: convert cidv0 to cidv1 · convert cidv1 dag-pb to cidv0 · re-encode cid version.**

## Decide before calling

Read the [versioned contract](/v1/tools/cid-version-convert/versions/1.0.0) and the supported scope below. Reuse `cid-version-convert@1.0.0` when your input, required output and limits match it. Choose another approach for an unsupported operation.

## Explain the choice

"I can use `cid-version-convert@1.0.0` for convert cidv0 to cidv1. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."

## Supported

- convert cidv0 to cidv1
- convert cidv1 dag-pb to cidv0
- re-encode cid version
- upgrade legacy cid envelope
- downgrade compatible cid envelope
- preserve cid multihash during conversion

## Not supported

- computing a CID from content
- converting non-dag-pb or non-sha2-256 CIDs to CIDv0

## Behavior

- Conversion preserves codec and multihash bytes.
- CIDv0 is permitted only for dag-pb with a 32-byte sha2-256 multihash.

## Input

- `cid` (string, required): max length 512
- `input_encoding` (one of "text", "hex", optional): default `"text"`
- `target_version` (one of 0, 1, required)
- `output_base` (one of "base32", "base58btc", optional): default `"base32"`

## Output

- `source_version` (integer, required)
- `target_version` (integer, required)
- `cid` (string, required)
- `bytes_hex` (string, required)
- `standard` (string, required)
- `reference` (string, required)
- `data_version` (string, required)

## Limits

- max text characters: 512
- max binary bytes: 256

## Example

Request input:

```json
{
  "cid": "QmYwAPJzv5CZsnAzt8auVZRnGi2hMrZrm2suKMaqWwaoFY",
  "target_version": 1
}
```

Response:

```json
{
  "result": {
    "source_version": 0,
    "target_version": 1,
    "cid": "bafybeie5nqv6kd3qnfjuprw2scvucpip3oda2pxyf7hyfasar4zu5flr5m",
    "bytes_hex": "017012209d6c2be50f70695347c6da90ab413d0fdb860d3ef82fcf8282408f334e9571eb",
    "standard": "Multiformats CID Specification 1.0",
    "reference": "CID specification 1.0 §CIDv0/§CIDv1 and multicodec/multihash/multibase tables",
    "data_version": "multiformats tables snapshot 2026-10-24"
  }
}
```

## How to call it

### MCP

Connect `https://computefirst.net/mcp` ([setup](/docs#connect)), then call `execute` with:

```json
{
  "id": "cid-version-convert",
  "version": "1.0.0",
  "input": {
    "cid": "QmYwAPJzv5CZsnAzt8auVZRnGi2hMrZrm2suKMaqWwaoFY",
    "target_version": 1
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/cid-version-convert/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"cid":"QmYwAPJzv5CZsnAzt8auVZRnGi2hMrZrm2suKMaqWwaoFY","target_version":1}'
```

The machine-readable contract is at [/v1/tools/cid-version-convert/versions/1.0.0](/v1/tools/cid-version-convert/versions/1.0.0).

### CLI

```sh
node cli.mjs run cid-version-convert 1.0.0 --input input.json --base-url https://computefirst.net
```

Get the client at [/clients/cli/](/clients/cli/).

## Related tools

- [Cid parse](/tools/cid-parse): Parse a CIDv0 or CIDv1 envelope without hashing content.
- [Segwit address encode](/tools/segwit-address-encode): Encode a witness program as a native segwit address using Bech32 for v0 and Bech32m for v1-v16.
- [Bech32 convert bits](/tools/bech32-convert-bits): Regroup integers between bit widths using BIP 173 rules, rejecting bad leftover padding.
- [Bech32 encode](/tools/bech32-encode): Encode lowercase HRP and 5-bit data as Bech32 or Bech32m text using that checksum.
- [Pem envelope format](/tools/pem-envelope-format): Format a label and lowercase hex bytes as a canonical RFC 7468 PEM envelope.
- [Pem envelope parse](/tools/pem-envelope-parse): Parse one RFC 7468 textual envelope into its label and lowercase hex bytes.
