JWK to PEM
Convert RSA and EC JSON Web Keys to PEM format in your browser.
Last updated: August 2026
Converts RSA and EC JWKs to PEM via Web Crypto, locally. Detects public vs private from the key material.
Was this tool helpful?
Two formats for the same key
A JWK is a JSON object describing a cryptographic key, common in OAuth and OpenID Connect where a server publishes its keys at a JWKS endpoint. PEM is the older Base64-and-headers format most libraries and command-line tools expect. Converting JWK to PEM lets you take a key fetched from a JWKS URL and feed it to tooling that only speaks PEM.
What actually gets converted
The conversion is a repackaging, not a cryptographic transform. For an RSA key, the JWK fields n (modulus) and e (exponent) are Base64URL-decoded and re-encoded as DER inside a PEM envelope. For an EC key, the curve and the x/y coordinates are mapped into the equivalent structure. No key material changes; only the serialization does.
Example
{
"kty": "RSA",
"n": "0vx7agoebGcQ...",
"e": "AQAB",
"kid": "2024-key"
}
-> -----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEF...
-----END PUBLIC KEY-----AQAB is the famous 65537 public exponent, which decodes to the bytes 01 00 01. The resulting PEM can be inspected structurally with the ASN.1 parser.
Public and private pieces
A public JWK has only n and e (or the curve point). A private JWK adds d and, for RSA, the prime factors p, q, and the CRT values. If those fields are present, the PEM you produce is a private key and must be handled as a secret, not shared like the public half.
FAQ
Which PEM header will I get? A public key yields a PUBLIC KEY block; a private key yields a PRIVATE KEY block. The header reflects whether private fields were present in the JWK.
Does the kid matter for conversion? No. The key id is just a label for selecting the right key from a set; it is not part of the math and is dropped in the PEM.