ForHosting KIT · Developer Utilities

PEM Base64 encoder

Wrap text the way certificates and keys are stored: standard Base64 folded into 64-character lines between matching -----BEGIN CERTIFICATE----- and -----END CERTIFICATE----- markers, or unwrap a block back to text. Free in your browser.

  • Free
  • Runs in your browser
  • No sign-up
  • Your data stays on your device
Use it from WebAPIEmailTelegramApp soon
If you enter
Label
CERTIFICATE
You get
Calculation mode
Encode
Line length
64
Bytes
205

Developers paste these blocks into configs, CI secrets, Kubernetes TLS secrets, and ACME challenge logs; support engineers re-wrap a continuous Base64 blob so OpenSSL will accept it; educators show how a CERTIFICATE header differs from a PRIVATE KEY header without installing a full crypto toolkit.

What a PEM block is made of

PEM, short for Privacy-Enhanced Mail, is the text envelope that almost every certificate, private key and public key file still uses. It has three parts: a BEGIN line with a label, a body of standard Base64 folded into lines of exactly 64 characters with a shorter final line when needed, and an END line with the same label. This tool turns your text into UTF-8 bytes, encodes them with the standard alphabet and equals padding, folds the result and adds both markers. The label is CERTIFICATE unless you choose another, such as PRIVATE KEY, RSA PRIVATE KEY, PUBLIC KEY or CERTIFICATE REQUEST.

Where PEM blocks are used and common mistakes

Developers paste PEM blocks into configuration files, CI secrets, Kubernetes TLS secrets and ACME challenge logs, and teachers use them to show how a CERTIFICATE header differs from a PRIVATE KEY header without installing a full crypto toolkit. When decoding, the tool removes the markers and returns the original UTF-8 text, accents and other scripts included. It stops with a clear message if the framing is broken, if the BEGIN and END labels do not match or if the body contains characters that are not valid Base64. Frequent slips are copying a block without its END line and editing the label on one side only.

How do I encode text as PEM Base64?

The result field is a multi-line PEM block with 64-character Base64 lines.

How do I decode a PEM block?

Send mode decode and put the full PEM (including BEGIN/END lines) in text.

What line length does PEM use here?

Body lines are folded at sixty-four characters, the classic PEM length used by certificates and keys.

Is the PEM Base64 encoder free?

The browser tool runs free on your device.

Which label should I put in the BEGIN and END lines?

CERTIFICATE is used unless you choose another label, such as PRIVATE KEY, RSA PRIVATE KEY, PUBLIC KEY or CERTIFICATE REQUEST. The same label goes on both lines. When decoding, the label is read from the block, and any label you give must match it.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/enc/base64-pem

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/enc/base64-pem \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"text":"Hello, PEM!"}'
{
  "text": "Hello, PEM!"
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "enc.base64_pem",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

Privacy-Enhanced Mail (PEM) is the text envelope almost every certificate, private key, and public key file still ships in: a Base64 payload folded into sixty-four-character lines between matching -----BEGIN LABEL----- and -----END LABEL----- markers. This PEM Base64 encoder converts either direction under a single mode field—encode turns UTF-8 text into a standards-shaped PEM block with classic line folding, decode strips the headers and recovers the UTF-8 payload—and rejects malformed framing, mismatched labels, and illegal Base64 with a clear invalid_input error. The free browser path and the prepaid API share the same pure algorithm so homework, docs, and pipelines never disagree on a newline. API success costs $0.002 per item; validation failures are not charged.

Encode text into a PEM block with 64-character lines

When label is omitted the engine uses CERTIFICATE, which matches the most common search intent for certificate pastes; other frequent labels include PRIVATE KEY, RSA PRIVATE KEY, PUBLIC KEY, and CERTIFICATE REQUEST. The engine serializes the string as UTF-8 bytes, maps those bytes to the standard Base64 alphabet with equals padding, then folds the continuous Base64 into lines of exactly sixty-four characters with a final shorter line when needed, and wraps the body between -----BEGIN LABEL----- and -----END LABEL----- using the same label on both sides. Multilingual text and punctuation round-trip because the path is full UTF-8, not a Latin-1 shortcut. Send a JSON body with the required string field text set to the plain UTF-8 payload you want to ship as PEM, leave mode at its default encode or set mode to encode explicitly, and optionally set label to the type string that should appear in the encapsulation boundaries. Empty payloads are legal: you still get a well-formed PEM with empty body and matching headers, which is useful for testing parsers. Optional aliases input, value, s, pem, and payload are accepted for the text field, and direction, op, and action for mode, so generated clients and older form names keep working. The response always includes result with the full multi-line PEM string, mode encode, label echoing the resolved type, line_length fixed at sixty-four, base64_body as the continuous Base64 without headers or newlines for clients that need both forms, and bytes equal to the UTF-8 length before encoding so tests can assert payload size.

Decode a PEM block and handle invalid input safely

Set mode to decode and put a complete PEM block in text, including the BEGIN and END lines. Leading and trailing whitespace around the block is tolerated so multi-line pastes from tickets and documentation still work. Body lines are trimmed and joined; spaces, tabs, and newlines inside the Base64 region are stripped, then the continuous alphabet is validated with the same rules as standard Base64: illegal characters, pads in the middle, more than two padding equals signs, or a length whose modulo four is one all fail with an explicit message. Prefer this capability when the search intent is PEM framing—headers plus sixty-four-character lines—rather than raw Base64 without encapsulation or URL-safe cookie alphabets that belong to sibling encoders. The engine locates the first -----BEGIN LABEL----- header, reads the label, finds the matching -----END LABEL----- footer, and rejects the request when the footer is missing, when the END label does not equal the BEGIN label, or when an unexpected encapsulation boundary appears inside the body. If you also pass label on decode, it must equal the label found in the block; a mismatch fails with invalid_input so automation can assert it received a PRIVATE KEY when a CERTIFICATE was pasted by mistake. After alphabet validation the bytes are decoded as UTF-8 with a fatal decoder, so non-text DER blobs that are not valid Unicode text also raise invalid_input instead of emitting replacement characters that would corrupt logs. Successful decode returns result as the recovered string, mode decode, label from the headers, line_length sixty-four, base64_body as the continuous body, and bytes as the decoded UTF-8 length. Validation failures are not charged on the prepaid API, so probing a suspicious paste is cheap for operators and safe for end users.

API usage, pricing, workflows, and practical limits

Call the free in-browser PEM Base64 tool for classroom demos, support playbooks, and one-off re-wrapping of a certificate paste without installing OpenSSL. A typical workflow encodes a short configuration secret as a labeled PEM for storage in a ticket system, then decodes it on the receiving service with mode decode and asserts that bytes and label match the original. Another workflow normalizes a continuous Base64 certificate body that arrived without line breaks: encode is not required if you already have PEM, but decode accepts folded or unfolded bodies as long as the BEGIN and END headers are present, and you can re-encode after inspecting result if you need canonical sixty-four-character folding again. Use the prepaid KIT API when a backend, serverless function, or SDK needs the same encode or decode step under balance at $0.002 per successful item; failed validation never consumes balance after the engine rejects the request. Pair this endpoint with plain Base64 tools when a pipeline must handle both unframed tokens and PEM-wrapped keys, but keep the landings separate so each page matches a single search intent—pem base64 encoder versus text to base64. Authors shipping SDKs can map the result field straight into a copy button, while label and line_length make OpenAPI examples self-explanatory for readers who only know the classic certificate file shape.

Certificate and key paste normalization

Re-wrap continuous Base64 or plain payloads into 64-character PEM lines with matching BEGIN/END labels so OpenSSL, Kubernetes secrets, and web servers accept the paste.

CI and docs golden checks

Pin encode and decode fixtures for CERTIFICATE and PRIVATE KEY samples so documentation and continuous-integration tests fail fast if PEM framing ever drifts.

Support and education

Agents and students convert text to PEM Base64 and back in the free browser widget, with clear invalid_input errors when headers are missing or labels mismatch.

What happens if the PEM is invalid?

Decode fails with invalid_input when headers are missing, BEGIN/END labels disagree, the Base64 body is illegal, or the payload is not valid UTF-8. The error message describes the problem; the request is not charged.

Read the full KIT documentation →