Skip to main content

Convert PEM and DER Certificate Formats in Browser Convert between PEM and DER certificate/key formats.

PEM/DER Converter illustration
🔐

PEM/DER Converter

Convert between PEM and DER certificate/key formats.

1

Choose mode

PEM to DER or DER to PEM.

2

Paste input

Paste your PEM or hex-encoded DER data.

3

Convert

Click convert to get the output.

Loading tool...

What Is PEM/DER Converter?

A PEM/DER Converter is a software utility that enables the conversion of cryptographic data between two formats: PEM (Base64-encoded text with headers) and DER (raw binary). This tool is commonly used by system administrators and developers who work with SSL/TLS certificates, as they need to convert certificate formats for different server platforms, such as Apache or Nginx, which use PEM format, and Java or Windows-based systems, which often require DER format. One specific problem it solves is the conversion of a certificate from PEM to DER when migrating a web application from an Apache server to a Java-based platform.

The tool's functionality allows users to input their data in either PEM or DER format and convert it to the other format, depending on their needs. What makes this particular implementation different is its client-side processing capability, which ensures that all conversions are performed locally without transmitting sensitive data over the network. The code also includes features such as automatic detection of the input format and error handling for incorrect inputs.

It supports both pem to der and der to pep conversions, allowing users to switch between these formats easily. For example, when converting from DER to PEM, it allows specifying a custom label for the output certificate, which can be useful in certain scenarios where specific key formats are required. The tool's functionality is also often referred to as a cert converter or key format converter due to its ability to handle various types of cryptographic data.

Why Use PEM/DER Converter?

  • Bidirectional
  • Custom labels
  • Certs/keys/CSRs
  • 100% client-side

Common Use Cases

Servers

Convert for servers.

Java

PEM to DER.

Windows

DER for cert stores.

Debug

Inspect DER hex.

Technical Guide

The conversion process from PEM to DER involves several steps, starting with the removal of headers and footers using a regular expression that matches strings like -----BEGIN CERTIFICATE----- and -----END CERTIFICATE----. The input string is then Base64-decoded using the atob function, which returns a binary string. This binary data is converted to hexadecimal format by iterating over each character in the string, obtaining its ASCII code with charCodeAt, converting it to a hexadecimal string with toString(16), and padding it with zeros if necessary. The resulting hex string is then output as the DER representation.

In the opposite direction, from DER to PEM, the process begins by removing any whitespace characters from the input hex string. It then creates an array of bytes using Uint8Array and populates it by parsing each pair of hexadecimal digits into a byte value with parseInt. These bytes are converted back into a binary string with String.fromCharCode, which is then Base64-encoded using btoa. The encoded string is formatted according to RFC 7468 by splitting it into lines of up to 64 characters and adding the appropriate PEM headers and footers, such as -----BEGIN CERTIFICATE----- and -----END CERTIFICATE----, depending on the label specified by the user.

Both conversion paths rely heavily on JavaScript's built-in functions for string manipulation, such as replace, match, and substring, as well as its support for binary data through Uint8Array. The use of React state management with useState allows the tool to dynamically update its output based on changes to the input or mode selection. When converting from DER to PEM, users can specify a custom label that will be used in the output headers, providing flexibility when working with different types of certificates or cryptographic data.

Tips & Best Practices

  • 1
    Set the mode to 'pem2der' or 'der2pem' before converting
  • 2
    Replace non-hex characters in DER input for accurate conversion
  • 3
    Use the 'PEM Label' field to specify certificate type in DER-to-PEM conversions
  • 4
    Paste PEM data without whitespace for successful conversion
  • 5
    Click the 'Copy' button to copy converted output to clipboard
  • 6
    Verify input format to avoid 'Error converting' messages

Related Tools

Frequently Asked Questions

Q Is the PEM/DER converter free?
Yes.
Q What is the difference between PEM and DER?
PEM = Base64 text, DER = binary.
Q Which format should I use for Linux vs Java?
PEM for Linux, DER for Java.
Q Is my data safe?
Yes.
Q Can it convert private keys?
Yes.

About This Tool

PEM/DER Converter is a free online tool by FreeToolkit.ai. All processing happens directly in your browser — your data never leaves your device. No registration or installation required.