PEM to DER Converter

Paste a PEM block and download the same bytes as a binary DER file. Whatever was inside, key or certificate, comes through unchanged.

FluffyShield Protected workspace
FluffyShield

Isolated workspace: other page scripts can't read your files. How FluffyShield works

Free · No upload · No sign-up · No usage quotas

Why is the DER file smaller than your PEM?

Because PEM spends four letters on every three bytes, and DER doesn't. A small key comes out about half the size, with nothing lost.

What the converter does
  1. Check the BEGIN label against what's inside
  2. Turn every four letters back into three bytes
  3. Hand you the bytes as a .der file

What it does

Not only keys

Certificates and signing requests go through as well.

PEM files too

A saved .pem file opens with Choose file, as well as pasted text.

Line breaks don't matter

Letters split over many short lines decode to the same bytes.

Limits Pasted text, or a PEM file of up to 16 MiB.

When a program wants DER and you have text

You've got a key or a certificate as a block of text that starts with -----BEGIN, and the program or device you're setting up wants a .der file instead. It's the same thing in another wrapping, and getting from one to the other loses nothing.

PEM is short for Privacy-Enhanced Mail. It dates from the days when email could only carry plain letters, so anything binary had to be spelled out in them to survive the trip. Email attachments still travel that way today, hidden from view.

DER is the binary data itself, the bytes before anyone spelled them out. A text editor can't show it sensibly, which is why the converter hands it to you as a download and doesn't show it in a box.

Where the extra size comes from

The spelling PEM uses is called Base64. It writes every three bytes as four letters, digits or signs. The sample key is 91 bytes, so its PEM needs 124 letters for them, and the BEGIN and END lines and line breaks add another 54 bytes on top.

Each DER file is the bytes of its PEM, without the letters

The sample public key

PEM 178 bytes
DER 91 bytes

The sample signing request

PEM 513 bytes
DER 327 bytes

Size, bytes

Both are test files from the site's own tests, put through this page's converter. How we checked

The sample signing request goes from 513 bytes to 327, nearer two thirds, because the two label lines count for less in a longer file. However long a file gets, the letters alone keep the PEM a third bigger than the DER.

Checking you've still got the same thing

A DER file isn't something you can read, so the converter reports on it before you save it. The last line of that report, SHA-256, is a fingerprint of the bytes: a long code that changes completely if a single byte does.

Run the downloaded file through FluffyBench Hash checksum with SHA-256 and you get the same code the report showed. Anyone holding the same key as DER gets it too, so comparing the whole code with theirs tells you both files hold the same bytes.

There's one check before the label goes. A DER file has nowhere to say what it is, so the converter makes sure the PEM's label was telling the truth while it still has one. We relabelled a signing request as PUBLIC KEY and got "The PEM label does not match the encoded public object."

Saving the .der file

In the box at the top of this page, FluffyBench's Certificate and public key inspector set to PEM to DER, the download button stays grey until the converter has read your block.

  1. Paste the PEM block into the Public key box, with its BEGIN and END lines.

  2. Check the report under What's inside. Object names what the block holds, and Bytes is the size the file will be.

    The report for the sample key: Object PUBLIC KEY, Bytes 91 and a long SHA-256 value, with Download DER above it.
    The report for the sample key: Object PUBLIC KEY, Bytes 91 and a long SHA-256 value, with Download DER above it.
  3. Press Download DER to save the file as public-object.der.

What it turns away

A private key is refused whatever its label, EC PRIVATE KEY included. The box puts up "That’s a private key" and says: "Private keys aren’t accepted. Paste only a certificate, a signing request or a public key, and keep the private key secret." A private key has no business in a web page, and the converter won't read it.

Two blocks pasted together, such as a certificate and the one that issued it, stop with "This operation accepts one public object. Use Certificate Chain Inspector for a certificate bundle." And a file that's already DER gets "PEM-to-DER needs PEM text or a PEM file, not a DER file."

You need the DER file turned back into text

DER to PEM Converter

It reads the file and writes the BEGIN line to match what it finds.

The program wants the key as JSON instead

PEM to JWK Converter

It reads a public key or the public key inside a certificate.

You have a bundle of certificates to look through

Certificate and public key inspector

Its Certificate chain tab reads a whole bundle and lines the certificates up by who issued which.

Search FluffyBench