JWK to PEM Converter

Convert keys between JWK (JSON Web Key) and PEM in either direction. Paste a JWK and get a PEM block, or paste a PEM key and get the equivalent JWK — the tool detects which you have and converts automatically. It supports RSA and EC (P-256/P-384/P-521) public and private keys, using the browser's built-in Web Crypto API, so your key material is processed entirely on your machine and never uploaded.

Output

How to use the JWK to PEM Converter

Paste your key into the input box. If it begins with { the tool treats it as a JWK and produces a PEM block; if it begins with -----BEGIN it treats it as PEM and produces a JWK. There's nothing to configure — the key type (RSA or EC), the curve, and whether it's a public or private key are all read from the key itself, and the output appears below ready to copy.

For JWK input, a d field marks a private key, which exports as a PKCS#8 PRIVATE KEY block; otherwise you get an SPKI PUBLIC KEY block. For PEM input, the tool reads modern PRIVATE KEY (PKCS#8) and PUBLIC KEY (SPKI) blocks. Legacy RSA PRIVATE KEY (PKCS#1) and EC PRIVATE KEY (SEC1) blocks can't be imported by the Web Crypto API directly — the status line tells you the one-line OpenSSL command to convert them to PKCS#8 first.

JWK and PEM: two ways to write the same key

A cryptographic key is just a set of numbers, but those numbers need a container before they can travel between systems, and JWK and PEM are the two you'll meet most often. PEM is the older, ubiquitous format: base64-encoded binary (DER) wrapped between -----BEGIN----- and -----END----- lines. It's what OpenSSL, web servers, SSH and most of the TLS world speak. JWK is the JSON-native format from the JOSE family of standards (the same world as JWT) — a plain object with fields like kty, n and e for RSA, or crv, x and y for EC — designed to drop straight into a JSON config, a JWKS endpoint, or an API request body.

Underneath, both describe the identical key; only the packaging differs. The need to convert comes up constantly: a JWT library hands you a JWK but your TLS stack wants PEM, or you've generated a PEM keypair with OpenSSL and need to publish the public half as a JWK at a /.well-known/jwks.json endpoint. RSA and EC are the two key families in everyday use — RSA being the long-established choice and EC (elliptic curve) the smaller, faster modern one, with P-256 the most common curve — and a converter has to understand both. The fiddly part is the binary encoding rules (PKCS#8 for private keys, SPKI for public ones, with the older PKCS#1 and SEC1 layouts still floating around), which is exactly the kind of detail that's easy to get wrong by hand.

This converter offloads that to the browser's Web Crypto API, the same vetted implementation that powers HTTPS in the page. It imports your key, then re-exports it in the other format, which means the conversion is exact and the math is handled by code that's already trusted for production cryptography. Crucially, the API runs locally: your private key is never transmitted, logged or stored, so you can convert real keys — not just test ones — without the risk that comes from pasting secrets into a remote service.

Common use cases

  • JWKS endpoints. Turn a PEM public key into the JWK you publish at /.well-known/jwks.json.
  • JWT signing. Convert a JWK handed to you by an identity provider into the PEM your library expects.
  • Cross-stack keys. Move a keypair between an OpenSSL/TLS world and a JOSE/JSON world.
  • Inspection. Read a key's type, curve and parameters by converting it to the more legible format.

Frequently asked questions

Which key types are supported?

RSA and EC (elliptic curve) keys, both public and private. For EC the standard curves P-256, P-384 and P-521 are supported. OKP keys such as Ed25519 aren't supported because most browsers' Web Crypto implementations don't expose them.

Is my private key safe to paste here?

Yes. The conversion uses the browser's built-in Web Crypto API and runs entirely on your device. Your key is never sent over the network, stored, or logged. You can verify this in your browser's developer tools — there are no outbound requests when you convert.

I get an error about PKCS#1 or SEC1 format. What do I do?

Blocks labelled "RSA PRIVATE KEY" or "EC PRIVATE KEY" use the older PKCS#1/SEC1 layout, which the Web Crypto API can't import directly. Convert to PKCS#8 first with OpenSSL — for example openssl pkcs8 -topk8 -nocrypt -in key.pem -out key.pk8.pem — then paste the result, which will be labelled "PRIVATE KEY".

What's the difference between PKCS#8 and SPKI?

They're the standard wrappers the tool produces: PKCS#8 ("PRIVATE KEY") for private keys and SPKI ("PUBLIC KEY") for public keys. Both are the modern, algorithm-agnostic formats, which is why the PEM output doesn't say "RSA" or "EC" in the header — the algorithm is encoded inside the data.

Why is there no "alg" in some output, or an unexpected one?

When converting PEM to JWK the tool imports the key for signing/verification, so the Web Crypto API may add a default alg hint such as RS256 or ES256. The key material (n, e or crv, x, y, d) is what matters and is correct; you can change or remove the alg field to suit your use.