JWK to PEM Converter

Paste one public JWK and get it back as a PEM block. A JWK with a secret in it is stopped before anything is written.

FluffyShield Protected workspace
FluffyShield

Isolated workspace: other page scripts can't read your files. How FluffyShield works

Free · No upload · No sign-up · No usage quotas

Is the JWK you were sent safe to paste?

Look for a line that starts with "d". A public key never has one.

What the converter does
  1. Look for any secret part in the JWK
  2. Let the browser load the key
  3. Write it out between BEGIN and END lines

What it does

Secrets stop it

A secret line hidden inside another part of the key still stops it.

Five kinds of key

RSA, EC keys on P-256, P-384 or P-521, and Ed25519.

Spacing doesn't matter

A JWK spread over many lines, or squeezed onto one, gives the same PEM.

Limits One key per paste, up to 16 MiB.

A key you were handed in curly brackets

A colleague has sent you a .jwk file, or a block of text that starts with a curly bracket, and a server you look after wants the key as PEM. Before it goes anywhere, it's worth knowing which half of a key pair you're holding.

Keys come in pairs. The private key is like a rubber stamp: whoever has it can sign. The public key is a print of that stamp. Anyone can hold a signature up against the print to check it, and nobody can sign anything with a print. So a public key is fine to paste into a web page, and a private key never is.

In PEM the difference is written on the first line, which says PUBLIC KEY or PRIVATE KEY. A JWK has no such line, and both halves look alike: curly brackets, short names, long runs of letters.

Telling a private JWK from a public one

Here's the sample key as the public JWK this page converts, beside the same key with its private part added.

Public: safe to sharePrivate: keep it{"kty": "EC","crv": "P-256","x": "pjb6n9…","y": "b_PmV8…"}{"kty": "EC","crv": "P-256","x": "pjb6n9…","y": "b_PmV8…","d": "••••••"}The d line is the secret

Public and private

The long values are cut short, and the private value is hidden. In a real private P-256 key it's a run of letters as long as x. How we checked

For an elliptic-curve key like this one, or an Ed25519 key, the private part is a single member, d. An RSA private key carries d too, with five more beside it: p, q, dp, dq and qi. A k is a different thing again, a secret shared by both sides that has no public half at all.

The converter looks for every one of these before it does anything else. Finding one gets this message: "Private or symmetric key material is not accepted. Remove it and provide a public JWK only." Nothing is converted.

If you see it, you've been handed the wrong half, or the whole pair. Go back to whoever sent the file and ask for the public key on its own.

What comes out the other side

The PEM block is the same key in the older form that tools like OpenSSL read: a BEGIN PUBLIC KEY line, the key spelled out in letters, and an END line.

Before writing a line, the converter checks that each value is the right length for the key's curve, and then has your browser load the key with its own cryptography. A damaged JWK fails there. We tried the sample key with one byte missing from x and got "The x value has the wrong byte length for this curve." Better to hear it now than from the server later.

What doesn't survive is the name tag. A JWK can say kid, alg, use and key_ops; a PEM block has nowhere to put them. Our sample key with "kid": "sample-p256" gave exactly the same PEM as the key without it. If anything downstream still looks keys up by their kid, keep the JWK file as well.

One key in, one PEM block out

The box at the top of this page, FluffyBench's Certificate and public key inspector set to JWK to PEM, takes a single key at a time: from one opening curly bracket to its closing one.

  1. Paste one key into the Public key box, from its opening { to its closing }.

  2. The PEM block shows under Result straight away, between its BEGIN and END lines.

    The Result box holding a PUBLIC KEY block of four lines, with Copy and Download above it.
    The Result box holding a PUBLIC KEY block of four lines, with Copy and Download above it.
  3. Press Download to save it as public-key.pem.

If what you have isn't one public key

Your file opens with "keys" and holds several keys

JWK and JWKS Inspector

It lists every key in the set with its kid, so you can tell which one to copy out. Pasted here, a whole set gets "PEM conversion accepts one public JWK. Select a key from the JWKS first."

You'll need a JWK again later

PEM to JWK Converter

It writes the key's kty, crv, x and y out again. It can't bring back a kid, since the PEM never had one.

You're not sure what kind of file you have

Certificate and public key inspector

It has a tab each for certificates, signing requests, JWKs and SSH keys, and reads them without changing anything.

Search FluffyBench