# Credential\_2.serialize

Serializes a credential into a JSON-serializable format.

## Imports

:::code-group
```ts [Named]
import { Credential_2 } from 'ox/webauthn'
```

```ts [Entrypoint]
import * as Credential_2 from 'ox/webauthn/Credential_2'
```
:::

## Examples

```ts twoslash
import { Registration, Credential } from 'ox/webauthn'

const credential = await Registration.create({
  name: 'Example'
})

const serialized = Credential.serialize(credential) // [!code focus]

// `serialized` is JSON-serializable — send it to a server, store it, etc.
const json = JSON.stringify(serialized)
```

## Definition

```ts
function serialize(
  credential: Credential,
): Credential<true>
```

**Source:** [src/webauthn/Credential.ts](https://github.com/wevm/ox/blob/main/src/webauthn/Credential.ts#L55)

## Parameters

### credential

* **Type:** `Credential`

The credential to serialize.

#### credential.attestationObject

* **Type:** `serialized extends true ? string : ArrayBuffer`

#### credential.clientDataJSON

* **Type:** `serialized extends true ? string : ArrayBuffer`

#### credential.id

* **Type:** `string`

#### credential.publicKey

* **Type:** `serialized extends true ? 0x${string} : { prefix: number; x: 0x${string}; y: 0x${string}; }`

#### credential.raw

* **Type:** `PublicKeyCredential`

## Return Type

The serialized credential.

`Credential<true>`
