Skip to content
ZeroServer.tools

PEM ↔ JWK Converter

Convert RSA PEM keys to JSON Web Key (JWK) format and back — all processing happens in your browser.

Supports RSA, EC (P-256/P-384/P-521) and Ed25519. The algorithm is read from the key's DER, not guessed from its PEM header — BEGIN PUBLIC KEY is the same wrapper for all three.

PEM vs JWK format

PEM (Privacy-Enhanced Mail) is a Base64-encoded DER format with -----BEGIN / END-----headers, used by OpenSSL, nginx, and most server software. JWK (JSON Web Key, RFC 7517) represents cryptographic keys as JSON objects, commonly used in OAuth 2.0, OIDC, and JWT ecosystems. This converter uses the browser's Web Crypto API — keys are never uploaded to any server.

Built and maintained by Meet Shah · Last updated

What this tool is used for

  • Publishing a public key at a JWKS endpoint when your key material is in PEM form.
  • Importing a JWK from an identity provider into a library that only reads PEM.
  • Reading the modulus and exponent out of a key while debugging a signature failure.
  • Adding a key id to a JWK so verifiers can select the right key during a rotation.
  • Confirming that two representations you were given are in fact the same key.

Frequently Asked Questions

What is the difference between PEM and JWK?
Packaging, not content. PEM is base64-wrapped DER with `-----BEGIN-----` headers — what OpenSSL, TLS and SSH use. JWK is the same key as a JSON object with named parameters, which is what JOSE, OAuth and WebCrypto expect.
Which PEM headers mean what?
`BEGIN PUBLIC KEY` is SPKI and `BEGIN PRIVATE KEY` is PKCS#8 — both carry an algorithm identifier inside. `BEGIN RSA PRIVATE KEY` is the older PKCS#1 form, which is RSA-only and is the usual cause of a "failed to load key" error in modern tooling.
What are n, e, d and the rest?
For RSA: `n` is the modulus and `e` the public exponent (almost always 65537), while `d`, `p`, `q`, `dp`, `dq` and `qi` are the private parts. For an elliptic-curve key you get `crv`, `x`, `y` and a private `d`. A JWK containing `d` is a private key — treat it accordingly.
What is a kid for?
Key rotation. The `kid` in a JWK Set lets a verifier pick the right key when several are published, and it matches the `kid` in a JWT header. Without one, a rotation forces every consumer to try each key in turn.
Is it safe to paste a private key here?
Conversion runs entirely in your browser using WebCrypto, and nothing is transmitted. Even so, treat any private key that has touched a clipboard or a browser tab as needing rotation if it protects something that matters.

Common errors and gotchas

  • Publishing a JWK that still contains the private parameters. Anything beyond the modulus and exponent must never be served.
  • Confusing the PEM headers. A public key, a private key and a certificate are three different blocks with the same look.
  • Omitting the key id, which makes rotation ambiguous the moment a JWKS holds more than one key.
  • Assuming the base64 inside a JWK is standard. It is Base64URL and unpadded, which trips manual decoding.
  • Copying a PEM block with a stray line break or missing header line, which most parsers reject outright.

Related Cryptography & Security tools

Private & free — this tool runs entirely in your browser.

IndieKitShip your Next.js startup in days.affiliate