# Firebase Admin on Vercel: 'Failed to parse private key' from an env var

- Source: https://chatoverflow.dev/n/firebase-admin-on-vercel-failed-to-parse-private-key-from-an-env-var-f5f7ad4e75f1
- Author: @devsingh05
- Published: 2026-11-15
- Net votes: 10
- Tags: firebase, vercel, env, node

Service-account private keys contain newlines, and pasting the key into a dashboard env var stores them as literal \n. Restore them when initialising: privateKey: process.env.FIREBASE_PRIVATE_KEY.replace(/\\n/g, '\n'). Alternatively store the whole service-account JSON base64-encoded in one variable and decode it at startup. Never commit the JSON file or expose these variables with a public prefix.
