b2KIT

JWK / PEM Key Converter

Convert between JWK (JSON Web Key) and PEM formats for RSA and EC keys. Supports PKCS#8 and SPKI formats.

Tested tool guide Tested browser tools Checked August 16, 2026

What JWK / PEM Key Converter does and how it behaves

JWK and PEM describe key material at different layers. This converter reads an RSA or EC JWK, or a PEM block, and emits the same key material in the selected counterpart format: PKCS#8 for a private key or SubjectPublicKeyInfo (SPKI) for a public key. It translates JWK base64url parameters into the ASN.1 DER structures carried by PEM, and reverses that mapping for PEM input. A common surprise is that JWK annotations such as kid, use, alg, and key_ops have no standard field-to-field representation in SPKI or PKCS#8.

How the result is produced

1

Mapping JWK parameters

For RSA, n and e provide the public modulus and exponent. A full two-prime private JWK also carries d, p, q, dp, dq, and qi. For EC, crv identifies the curve, x and y give the public point, and d supplies the private value. The RSA integer members and EC coordinate and private-value members use unpadded base64url. Private output is impossible when only public parameters are present.

2

Selecting the PEM wrapper

PEM is the textual envelope around base64-encoded DER. A BEGIN PUBLIC KEY block holds SubjectPublicKeyInfo, which contains an algorithm identifier and the public-key bit string. A BEGIN PRIVATE KEY block holds unencrypted PKCS#8 PrivateKeyInfo, which identifies the algorithm and wraps its private-key value. Conversion changes the container and textual encoding; it neither generates a new key pair nor recovers secret material from a public key.

Good uses

  • Publish an RSA or EC public key as JWK when a service gives you only a BEGIN PUBLIC KEY SPKI block.
  • Supply a PKCS#8 BEGIN PRIVATE KEY file to software that received the same RSA or EC private key as JWK.
  • Normalize two public-key encodings to JWK so you can compare RSA n and e or EC crv, x, and y values.

Limits and checks

  • Private JWK members and BEGIN PRIVATE KEY blocks are secret material. Processing stays in the browser and is not uploaded by this tool, but copied results can still enter clipboard history, logs, shell history, or an unintended destination.
  • PEM is an envelope, not one key format. BEGIN RSA PRIVATE KEY (PKCS#1), BEGIN EC PRIVATE KEY, BEGIN CERTIFICATE, and BEGIN ENCRYPTED PRIVATE KEY are not the same wrappers as the advertised PKCS#8 PRIVATE KEY and SPKI PUBLIC KEY forms.
  • Equivalent keys need not have identical text. PEM line wrapping and base64 presentation can differ, and a PEM round trip has no standard way to preserve JWK fields such as kid, use, alg, or key_ops. Compare the actual key parameters when checking equivalence.

Common questions

Can I convert a public JWK into a PKCS#8 private key?

No. An RSA or EC public JWK contains only the values needed for public-key operations. Select SPKI for that material. PKCS#8 private output requires secret parameters, such as an EC d value or RSA private integers. Those values are absent from a public JWK and cannot be reconstructed by changing its format.

Why does the converted JWK not retain kid or alg?

SPKI and PKCS#8 encode cryptographic key structures, not the JOSE annotations attached to a JWK. A PEM block normally provides no kid, use, key_ops, or JOSE alg value to recover. Add those fields only from the surrounding application's configuration and policy; do not infer an alg merely from seeing an RSA or EC key.

References and verification

The behavioral notes were checked against the browser implementation. Standards and primary references below define the relevant format, formula, or platform behavior.

Related Tools