Skip to content
ZeroServer.tools

.env to JSON

Convert .env files to JSON — parse KEY=VALUE pairs into a JSON object.

or drop a file here
JSON Output

.env to JSON Converter

Environment files (.env) store configuration as KEY=VALUE pairs, but some tools and APIs expect JSON objects. This converter parses your .env file line by line: blank lines and # comments are skipped, and values are split on the first =. Surrounding single or double quotes are stripped. With Infer typesenabled, true/false become JSON booleans and numeric strings become numbers. Everything runs in your browser — no data is sent to any server.

Built and maintained by Meet Shah · Last updated

What this tool is used for

  • Turning a local `.env` file into the JSON a deployment platform or a secrets manager accepts.
  • Producing a structured view of environment variables for a configuration audit.
  • Comparing two environments by converting both files and diffing the objects.
  • Building a fixture that mirrors real environment configuration.
  • Checking how a parser will treat quoting and inline comments in your file.

Frequently Asked Questions

Why is the pasted file not in the shared link?
Because a .env file is the most credential-dense format there is. Every option on this page stays URL-bound so a shared link reproduces your settings, but the file content is held in memory only — never in the address bar, the copied link, or browser history.
Should I leave type inference on?
Not for identifiers. It is right for PORT=5432 and destructive for digit strings: ACCOUNT=0012345 becomes 12345 and VERSION=1.10 becomes 1.1. Leading and trailing zeros cannot be recovered from the number afterwards, so anything that is a label rather than a quantity should stay a string.
What else can type inference change unexpectedly?
Infinity is a valid JavaScript number with no JSON representation, so TIMEOUT=Infinity serialises as null. Hex literals count as numeric, so FLAG=0x1A becomes 26. And an integer above 2⁵³ − 1 loses its final digits, because JSON numbers are doubles.
Are inline comments stripped?
No. PORT=5432 # main keeps the whole tail as its value, and since that is not numeric it stays a string. Several dotenv implementations do strip unquoted trailing comments, so a file your app reads fine can convert differently here. Put comments on their own line.
Which .env features are unsupported?
Values spanning multiple lines, the export KEY=value form — export becomes part of the key — and variable expansion, where ${OTHER} is copied through literally rather than resolved. Parsing splits each line at the first = and strips one matched pair of surrounding quotes.

Common errors and gotchas

  • Committing the result. A `.env` is usually gitignored precisely because it holds secrets, and the JSON is not safer.
  • Losing quoting rules, where a quoted value keeps spaces and an unquoted one may not.
  • Assuming multiline values survive, since the format's support for them varies by implementation.
  • Treating an inline `#` as a comment inside a quoted value, where it is data.
  • Expecting types. Every environment variable is a string, however numeric it looks.

Related Converters tools

Private & free — this tool runs entirely in your browser.

IndieKitShip your Next.js startup in days.affiliate