Security

PEM & ASN.1 Decoder — Inspect Keys, CSRs and DER Data Online

Decode PEM, base64 or hex DER into an ASN.1 tree, and identify public keys with their size and SPKI hash.

Runs entirely in your browser — nothing you paste is uploaded or stored.

Decoded in your browser. Private keys are refused, so a mistaken paste is never processed.

What is pem & asn.1 decoder?

Almost every cryptographic file format, including public keys, certificates, certificate requests, PKCS#7 bundles and revocation lists, is a PEM wrapper around a binary structure called ASN.1 DER. When something does not parse, or you simply want to know what a blob contains, you need to see that structure. This tool turns PEM, base64 or hex into a readable tree: each element with its type, its value, its byte offset and its length, and with the structures hidden inside bit strings and octet strings opened up. Well-known object identifiers are named, so 1.2.840.10045.3.1.7 reads as P-256. For public keys it also reports the algorithm, key size and curve, and the SHA-256 hash of the key (the value used for key pinning). Everything is decoded in your browser, and private keys are refused on purpose.

When to use it

  • Finding out what a PEM file actually contains when its BEGIN line is missing, wrong or misleading.
  • Checking the algorithm, key size or curve of a public key without installing OpenSSL.
  • Getting the SHA-256 SPKI hash of a public key for pinning or for comparing two keys.
  • Debugging a structure that another tool rejects, by seeing exactly where the encoding goes wrong.
  • Learning how X.509, PKCS#7 or CSR data is laid out, one element at a time.

How to use this tool

  1. Paste PEM text, or the base64 or hex of a DER structure, or click "Load example" for a sample.
  2. Read the summary above the tree if the input is a public key. Tick "Show offsets & lengths" to see byte positions.
  3. Use "Copy tree" to copy the decoded structure as indented text.
  4. For a certificate or certificate request, use the X.509 Certificate Decoder for a plain-language review. This tool shows the raw structure.

Example

An EC P-256 public key in PEM form.

Input

-----BEGIN PUBLIC KEY-----
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEfVClMwl+Akw58wS5ghiJoGHIg098
gcHiALh/8hdXM5E9DF+lUcpa8jiZFnifOT7YZY3w7O9maTo9Y6CE+B+CnQ==
-----END PUBLIC KEY-----

Output

SEQUENCE (2 elem)
  SEQUENCE (2 elem)
    OBJECT IDENTIFIER 1.2.840.10045.2.1 (EC)
    OBJECT IDENTIFIER 1.2.840.10045.3.1.7 (P-256 (prime256v1))
  BIT STRING 520 bits 04 7D 50 A5 33 09 7E 02 4C 39 F3 04 B9 82 18 89 …

The first inner element names the algorithm (EC) and the second the curve (P-256). The bit string is the public point, which starts with 04 for an uncompressed key.

Reading an ASN.1 tree

Each line is one element. A SEQUENCE is an ordered list of other elements, and its element count is shown in brackets. An OBJECT IDENTIFIER is a dotted number that names an algorithm, a curve or an attribute, and this tool adds the common names next to the numbers. An INTEGER is shown in decimal when it is small and as hexadecimal with its bit length when it is large, which is how an RSA modulus appears. Square brackets such as [0] are context-specific tags: the meaning depends on the structure they sit in, and the format’s specification says which field each one is.

The parser is the same bounds-checked DER reader that powers the X.509 Certificate Decoder, with limits on nesting and size so that a hostile or damaged input produces an error, not a frozen tab.

Frequently asked questions

Why are private keys refused?

A private key is a secret, and pasting one into any web page is a risk worth avoiding even when, as here, nothing is uploaded. The tool refuses anything labelled as a private key (PRIVATE KEY, RSA PRIVATE KEY, EC PRIVATE KEY, ENCRYPTED PRIVATE KEY and similar), and it also recognises unlabelled private keys by their structure. To inspect a key pair, decode the public half. With OpenSSL, openssl pkey -in key.pem -pubout prints it.

Is anything sent to a server?

No. The data is decoded in your browser tab and never uploaded. The one thing the tool computes beyond parsing is a SHA-256 hash, which uses your browser's built-in cryptography.

What is the SPKI hash for?

SPKI is the SubjectPublicKeyInfo, the standard encoding of a public key. Its SHA-256 hash identifies a key independent of any certificate, so it is used for key pinning and for checking that a certificate, a request and a key all belong together. The tool shows it as hex and as base64.

What is the difference between this and the X.509 Certificate Decoder?

This tool shows the raw structure of any ASN.1 data, element by element. The X.509 Certificate Decoder understands certificates and certificate requests specifically. It explains the subject, validity, alternative names and extensions in plain language, and flags problems. Use this one for keys, unknown data and learning, and the other for reviewing a certificate.

What do the offset and length numbers mean?

The offset is the byte position of the element within the data. The two numbers after it are the length of the header (the tag and length bytes) and the length of the content. They match what OpenSSL's asn1parse command prints as the offset, hl and l fields.

Why does it open some bit strings and octet strings but not others?

In DER, those two types often wrap another encoded structure, such as the RSA key inside a public key. The tool opens one only when its contents parse completely as a structure, so a random hash or a raw EC point stays as plain bytes instead of being misread.

Why can't it decode my file?

The error says where the structure breaks, and the common causes are a PEM block cut off while copying, extra characters added by an email or chat tool, or a file that is not DER at all. Some formats, such as PGP and SSH keys, are different encodings and are not ASN.1. If you have a binary .der file, convert it to base64 or hex first.

Find these tools useful? A coffee helps keep them free and ad-light.

Buy me a coffee