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.
How to use this tool
- Choose "PEM → one line" to flatten a key, or "One line → PEM" to restore one.
- Paste the key or certificate. Windows line endings, quotes around the value and several blocks in a row are all fine.
- Pick the one-line style: with \n for .env and JSON, the whole PEM as Base64, the Base64 body only, or spaces.
- 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.
More developer tools
Key Pair Generator
RSA, ECDSA and Ed25519 key pairs as PEM, PKCS#1, OpenSSH and JWK, with the SSH fingerprint.
Open tool →Base64 Encode & Decode
Text and files to Base64 or Base64URL, data URIs, and Base64 back to text, hex or a file.
Open tool →Secret Key Generator
Random secrets in hex, Base64 or Base64URL, API keys and passwords, with the entropy shown.
Open tool →