# JwkToKey()

Converts a JWK (JSON Web Key) back into a usable key object for signing or verification.

Accepts a struct or JSON string. Typically used after loading keys from an OAuth/OIDC provider's JWKS endpoint.

**Requires Extension:** [Crypto Extension](https://download.lucee.org/#17AB52DE-B300-A94B-E058FC978BE4542D)

```
JwkToKey( jwk=any );
```

**Returns:** any

# Arguments

| Argument | Type | Required | Description | Default |
|----------|------|----------|-------------|---------|
| jwk | any | Yes | JWK as a struct or JSON string |  |

# Examples

```cfml
// Convert a JWK (JSON Web Key) back into a Java key object for signing/verification
// Accepts a struct or a JSON string

// Roundtrip: generate key pair -> export to JWK -> import back
kp = GenerateKeyPair( "RSA" );
jwk = KeyToJwk( kp.public );
publicKey = JwkToKey( jwk );

// Use the imported key to verify a JWT
token = JwtSign( { sub: "user123" }, kp.private );
claims = JwtVerify( token, publicKey );
// claims.sub == "user123"

// Also accepts a JSON string directly
json = serializeJSON( jwk );
publicKey = JwkToKey( json );

// Works with EC and Ed25519 keys too
ecKp = GenerateKeyPair( "P-256" );
ecJwk = KeyToJwk( ecKp.public );
ecPublicKey = JwkToKey( ecJwk );
```







# Categories

[Cryptography](../../categories/crypto.md)

# See Also

[JwksLoad()](jwksload.md), [KeyToJwk()](keytojwk.md)