Developer

ENV to JSON Converter

Convert a .env file into JSON, with correct handling of quoting, multi-line values, comments and exported variables.

Output

Need this built for your product?

We design, build & host secure software & APIs.

Talk to an engineer

There is no .env specification

The dotenv format grew out of a Ruby library and was copied into every other ecosystem with variations. Whether values can span lines, whether quotes are stripped, whether export prefixes are allowed, and how comments after a value are treated all differ between implementations. A converter has to pick a behaviour, and the safest assumption is the most common one: strip surrounding quotes, allow export, treat a hash as a comment only when it starts a line or follows whitespace.

Quoting changes meaning

An unquoted value has surrounding whitespace trimmed. A double-quoted value keeps whitespace and typically expands escape sequences such as newline. A single-quoted value keeps whitespace and is entirely literal. So the same characters produce three different values depending on the quotes, and converting without honouring that changes your configuration.

Everything is a string

Environment variables are strings by definition. Converting to JSON tempts a converter to infer types, turning the text true into a boolean and 8080 into a number. That is frequently wrong: a port read from an environment variable is normally expected as a string by the code reading it, and a value like 0644 loses its leading zero. Keeping strings matches how the file is actually consumed.

Comments and blank lines

Lines starting with a hash are comments and disappear. A hash later in a line is ambiguous: inside a quoted value it is literal, outside one it usually starts a comment. Getting that wrong truncates values containing a hash, which happens most often in passwords and URLs with fragments.

Never commit the output

A .env file holds credentials, which is why it belongs in .gitignore. Converting it to JSON does not change that, and a config.json full of secrets committed to a repository is a routine and serious leak. Convert for inspection or transformation, then handle the result with the same care as the original.

Frequently Asked Questions

Privacy & Security

Converted locally in your browser. No data is sent to any server.

Data: None
Client-side-Side
Active
v1.0

How to Use

Paste .env content to convert into JSON.

Disclaimer: This tool is provided "as is" without warranty of any kind. Results are for educational and utility purposes.