> For the complete documentation index, see [llms.txt](https://docs.twine.world/twine-js/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.twine.world/twine-js/twine-protocol/twine-core/functions/ascid.md).

# asCid

[**@twine-protocol/twine-core v0.1.0**](/twine-js/twine-protocol/twine-core/index.md) • **Docs**

***

[twine-js](/twine-js/index.md) / [@twine-protocol/twine-core](/twine-js/twine-protocol/twine-core/index.md) / asCid

## Function: asCid()

> **asCid**(`val`): `null` | [`CID`](/twine-js/twine-protocol/twine-core/classes/cid.md)<`unknown`, `number`, `number`, `Version`>

Convert something into a CID

### Parameters

| Parameter | Type  | Description          |
| --------- | ----- | -------------------- |
| `val`     | `any` | The value to convert |

### Returns

`null` | [`CID`](/twine-js/twine-protocol/twine-core/classes/cid.md)<`unknown`, `number`, `number`, `Version`>

The CID or null if it could not be converted

### Example

```js
const cid = asCid('bafybeib3...')
const anotherCid = asCid(somePulse)
```

### Defined in

[packages/twine-core/src/conversion.ts:96](https://github.com/twine-protocol/twine-js/blob/3800995f9c83f4f5711bcf3062ea754a1e4448ce/packages/twine-core/src/conversion.ts#L96)
