b2KIT

PEM to DER Converter

Convert certificates and keys between PEM (Base64 text) and DER (binary) encoding formats.

Tested tool guide Tested browser tools Checked August 16, 2026

What PEM to DER Converter does, with a checked example

PEM and DER are two containers for the same certificate or key data. PEM is the readable form: base64 text wrapped in lines like -----BEGIN CERTIFICATE-----. DER is the raw binary inside that wrapping. This tool converts either direction by adding or removing the armor lines and base64-encoding or decoding, so the underlying bytes never change. Everything runs in the browser; nothing is uploaded. The surprise for most users: conversion does nothing beyond re-wrapping. It does not encrypt, decrypt, sign, or validate. A PEM file is not an encrypted 'safe text' version of DER; it is the identical data presented differently, and converting cannot fix a broken certificate.

Worked example

A concrete input and expected output from the current implementation.

Input

-----BEGIN CERTIFICATE-----
MAMCAQE=
-----END CERTIFICATE-----

Expected output

30 03 02 01 01 (the five DER bytes, shown as hexadecimal)

Removing the two armor lines leaves MAMCAQE=, which base64-decodes to five bytes: 30 03 02 01 01. That is a DER SEQUENCE (0x30) three bytes long (0x03) wrapping an INTEGER (0x02) of length 1 (0x01) with value 1 (0x01). A real certificate is the same encoding with dozens of fields; this tiny block only illustrates the transformation.

How the result is produced

1

PEM to DER: strip and decode

To convert PEM to DER, drop the -----BEGIN ...----- and -----END ...----- lines and any trailing whitespace, then base64-decode the remaining text into bytes. What is left is the DER encoding itself: a length-prefixed ASN.1 structure, in practice a SEQUENCE holding certificate fields or key integers such as modulus and exponent. No other transformation applies, so the certificate's binary form emerges byte for byte.

2

DER to PEM: encode and wrap

Converting DER to PEM runs the process backward: base64-encode the binary, break the text into 64-character lines, and surround it with a BEGIN/END pair whose label (CERTIFICATE, PRIVATE KEY, and so on) announces the payload type. The label is a hint for whatever program reads the file, so matching it to the content matters more than the encoding mechanics, which are a plain round trip.

Good uses

  • A certificate arrives from a CA or colleague as a .pem file, but the device or service that must consume it (a load balancer, a hardware token, a Java keystore import) expects the binary .der form.
  • You are debugging an ASN.1 parse error or a TLS handshake failure and need the raw certificate bytes as hex, to compare against what the server actually sent on the wire.
  • You are building test fixtures or publishing into an LDAP directory, where some consumers require the exact DER byte value and the PEM on disk is just the armoring you must undo first.

Limits and checks

  • The conversion is purely mechanical and validates nothing. An expired, self-signed, or tampered certificate converts as happily as a valid one, and corrupted input produces garbage bytes without an error. Checking signatures, expiry, and trust chains is a separate step with different tooling.
  • The armor label records real format differences. -----BEGIN RSA PRIVATE KEY----- (PKCS#1) and -----BEGIN PRIVATE KEY----- (PKCS#8) wrap different structures, and converting either to DER preserves that difference. If a consumer rejects your DER, the cause may be PKCS#1 versus PKCS#8, or RSA versus EC, not the PEM/DER encoding.
  • Legacy passphrase-protected PEM (the Proc-Type: 4,ENCRYPTED header under the BEGIN line) must be decrypted before conversion; pasting an encrypted block yields unusable bytes. Also, DER output is binary: expect to save it as a file rather than paste it back into a text box.

Common questions

Is a .der file just a smaller copy of my .pem file?

Essentially yes. Both hold the same DER bytes; the PEM version is larger because base64 text expands the data by about a third and the armor lines add overhead. Nothing is encrypted or compressed in either direction, so converting never changes the certificate's meaning, only how it is presented to other software.

Will converting fix a certificate that is being rejected?

No. PEM and DER hold identical bytes, so a certificate that fails validation in one form fails the same way in the other. If a system rejects your file, check the armor label and inner format (PKCS#1 versus PKCS#8), whether the private key matches the certificate, and the trust chain. Re-encoding repairs none of those.

References and verification

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

Related Tools