> **Can't find what you're looking for?** Use `search_docs` on the docs MCP server at `https://v3.viem.sh/api/mcp` to find what you need.

# Mnemonic.toPrivateKey

:::info
`Mnemonic.toPrivateKey` is a re-export of ox's [`Mnemonic.toPrivateKey`](https://oxlib.sh/api/Mnemonic/toPrivateKey). Refer to the ox documentation for the full reference.
:::

Converts a mnemonic to a private key.

## Imports

```ts
import { Mnemonic } from 'viem/utils'
```

## Examples

```ts twoslash
// @noErrors
import { Mnemonic } from 'viem/utils'

const mnemonic = Mnemonic.random(Mnemonic.english)
const privateKey = Mnemonic.toPrivateKey(mnemonic)
// @log: '0x...'
```

### Paths

You can derive a private key at a specific path using the `path` option.

```ts twoslash
// @noErrors
import { Mnemonic } from 'viem/utils'

const mnemonic = Mnemonic.random(Mnemonic.english)
const privateKey = Mnemonic.toPrivateKey(mnemonic, {
  path: Mnemonic.path({ index: 1 }) // 'm/44'/60'/0'/0/1' // [!code focus]
})
// @log: '0x...'
```

## Definition

```ts
function toPrivateKey<as>(
  mnemonic: string,
  options?: toPrivateKey.Options<as>,
): toPrivateKey.ReturnType<as>
```

## Parameters

### mnemonic

* **Type:** `string`

The mnemonic to convert.

### options

* **Type:** `toPrivateKey.Options<as>`
* **Optional**

Conversion options.

#### options.as

* **Type:** `"Bytes" | "Hex" | as`
* **Optional**

The output format.

#### options.passphrase

* **Type:** `string`
* **Optional**

An optional passphrase for additional protection to the seed.

#### options.path

* **Type:** `string`
* **Optional**

An optional path to derive the private key from.

## Return Type

The private key.

`toPrivateKey.ReturnType<as>`
