FormatterHQ

DER to PEM Converter

Upload a .der, .cer or .key file, or paste its hex or Base64, and get PEM text with the right header. The type is detected automatically from the ASN.1 structure.

Input TEXT
Output TEXT
Ready.

How to use the DER to PEM Converter

  1. Upload a binary .der, .cer, .crt, .key, .p8 or .bin file, or paste the DER bytes as hex or Base64.
  2. Leave PEM type on Detect automatically, or choose a label such as CERTIFICATE or PRIVATE KEY yourself.
  3. Click Convert to PEM.
  4. Copy the PEM block into your config file or save it with a .pem extension.

Turn binary data into text with this DER to PEM converter

Most web servers, JWT libraries and configuration files expect keys and certificates as PEM text. When you receive a binary DER file, for example a .cer downloaded from a Windows CA or a key exported from a Java keystore, this der to pem converter wraps it in Base64 with the correct BEGIN and END lines.

Example

The sample input is a DER public key written as hex:

3059301306072a8648ce3d020106082a8648ce3d030107034200042…

Converting it produces:

-----BEGIN PUBLIC KEY-----
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEJrocOMVB3s0sRD/b5ehRYgQ/NQNr
PZSYWe+8QUcO6PZIPPOeKruikbZtTIN2h1yQSOOFVuP7AMptTjD+lpKYag==
-----END PUBLIC KEY-----

The status line reads "91 bytes → PUBLIC KEY PEM". The Base64 body is wrapped at 64 characters, as the PEM standard requires.

How the PEM type is detected

PEM labels matter: software decides how to parse the block from its BEGIN line. With Detect automatically, the converter examines the top-level ASN.1 structure and chooses one of these labels:

  • CERTIFICATE or CERTIFICATE REQUEST: a signed structure of three parts, told apart by the fields inside.
  • PUBLIC KEY (SPKI) or RSA PUBLIC KEY (PKCS#1).
  • PRIVATE KEY (PKCS#8), RSA PRIVATE KEY (PKCS#1), EC PRIVATE KEY (SEC1) or ENCRYPTED PRIVATE KEY.
  • PKCS7: a certificate bundle such as a .p7b file.

If the structure is not recognized, the label falls back to CERTIFICATE. Choose the type from the list when you know better, for example for an X509 CRL.

Input formats

Hex may contain spaces, colons or a 0x prefix. Anything that is not hex is read as Base64, including Base64URL. The bytes are parsed as ASN.1 before conversion, so truncated or corrupted data is reported instead of being silently wrapped.

Common errors and fixes

  • "This is already PEM": the input contains a BEGIN line, so no conversion is needed. Use PEM to DER for the reverse direction.
  • "runs past the end of the data": the file is incomplete or is not DER. If you upload a PEM text file by mistake, the tool detects the BEGIN line and tells you it is already PEM.
  • Wrong label in the output: override it with the PEM type selector.

Once you have PEM, you can read a certificate with the certificate decoder or turn a key into a JWK with PEM to JWK.

Privacy

Files are read and converted in your browser. Nothing is uploaded to a server.

Frequently asked questions

How do I convert a .cer file to .pem?
Upload the .cer file and click Convert to PEM. If the file already starts with -----BEGIN CERTIFICATE-----, it is PEM and you can simply rename it to .pem.
What is the openssl command for DER to PEM?
For a certificate, run openssl x509 -inform der -in cert.der -out cert.pem. For keys, use openssl pkey -inform der -in key.der -out key.pem. This page produces the same result without installing anything.
Why did my private key get the PRIVATE KEY label instead of RSA PRIVATE KEY?
The label follows the structure. A PKCS#8 key is labeled PRIVATE KEY even when it contains an RSA key, while a bare PKCS#1 key gets RSA PRIVATE KEY. Both are correct for their contents.
Can I convert hex copied from a debugger or Wireshark?
Yes. Paste the hex with or without spaces or colons. Remove any offsets or ASCII columns first, because only the hex bytes themselves can be converted.

Last updated September 26, 2026

Related tools