Dotenv multiline variables

From the documentation Brian posted above:

Alternatively, multi-line values with line breaks are now supported for quoted values.

So the solution you sketched in your question is legit now!


Did you try reading the documentation?

Multi-line values

If you need multiline variables, for example private keys, you can double quote strings and use the \n character for newlines:

PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----\nHkVN9…\n-----END DSA PRIVATE KEY-----\n"