Lihat halaman ini dalam Bahasa IndonesiaVer esta página en españolVer esta página em portuguêsDiese Seite auf Deutsch ansehen

PEM to One Line Converter

Environment variables, JSON config files and CI secrets want a single line, but PEM keys and certificates are many lines. Paste the key here to get it on one line with \n escapes, as Base64, or as the bare body, and turn any of those back into a normal PEM file.

Runs 100% in your browser: keys and data are never uploaded
Loading the tool…

How to use this tool

  1. Choose "PEM → one line" to flatten a key, or "One line → PEM" to restore one.
  2. Paste the key or certificate. Windows line endings, quotes around the value and several blocks in a row are all fine.
  3. Pick the one-line style: with \n for .env and JSON, the whole PEM as Base64, the Base64 body only, or spaces.
  4. Copy the result. For the \n style a ready .env line and the code to read it back are shown too.

What this tool can do

One line with \n

Line breaks become the two characters \n, the form that dotenv files, JSON strings, Firebase service accounts and most CI secret fields expect.

Base64 of the whole file

Encodes the entire PEM, BEGIN and END lines included, as Base64. Useful where even backslashes cause trouble; decode it in code before use.

Back to PEM

Reads a value with \n escapes, a JSON-quoted string, a Base64-encoded PEM file or a bare Base64 body, and rewrites it as a standard PEM with 64-character lines.

Any PEM block

Private and public keys, RSA and EC keys, certificates and certificate chains. Each block is kept separate and checked as valid Base64.

Tips and common problems

error:1E08010C or "invalid PEM" after loading the key

The variable still holds the literal characters \n. Replace them with real line breaks in code, for example key.replace(/\\n/g, "\n") in Node.js.

Docker or the shell drops part of the value

Keep the value in double quotes in .env. If quoting is not possible, use the Base64 style and decode it in your application.

Only the Base64 body was given to me

Use "One line → PEM" and choose the type, such as PRIVATE KEY or CERTIFICATE, so the right BEGIN and END lines are added.

Frequently asked questions

How do I put a private key in a .env file?

Convert it with the \n style and paste it in double quotes: PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\nMIIE...\n-----END PRIVATE KEY-----\n". In code, turn \n back into line breaks before loading the key.

Is my key uploaded?

No. The conversion runs in your browser and the key never leaves your device.

Does it work with certificates and chains?

Yes. Any PEM block works, and several blocks in a row (a certificate chain) stay separate blocks when converted back.

Which style should I use for GitHub Actions or Vercel secrets?

Those fields accept multi-line values, so you can paste the PEM as it is. Use the \n style when the value goes into a .env file or a JSON string.