.env to JSON Converter (and JSON to .env)
Convert .env files to JSON and JSON back to .env. Handles quotes, comments, and the export prefix. Runs entirely in your browser.
How to use .env ↔ JSON
- 1Pick a direction
Choose .env → JSON or JSON → .env. Use Swap to flip the output back into the input.
- 2Paste your input
Paste a .env file or a JSON object into the left pane.
- 3Read the result
The converted output appears live on the right. Errors are flagged below.
- 4Copy
Click Copy to put the result on your clipboard.
About .env ↔ JSON
A .env file and a JSON object hold the same thing — a set of key/value configuration pairs — but in two formats that different tools expect. .env files are the standard for local development and twelve-factor apps, read by dotenv and most frameworks, while JSON is what scripts, CI systems, secret managers, and serverless platforms usually want. Converting between them by hand is fiddly and easy to get subtly wrong, which is exactly where small details bite.
This converter handles those details in both directions. Going from .env to JSON, it skips blank lines and # comment lines, drops the optional "export " prefix, and respects quoting: double-quoted values are unescaped (so \n becomes a real newline and \" becomes a quote), single-quoted values are kept literal, and a # inside quotes is treated as part of the value rather than the start of a comment. Unquoted inline comments are stripped, and every value is emitted as a JSON string because that is what .env values always are.
Going from JSON to .env, each top-level key becomes a KEY=value line. Values that contain newlines, tabs, quotes, a #, or leading and trailing spaces are automatically wrapped in double quotes and escaped so they survive a round-trip; simple values are left bare for readability. Nested objects and arrays are serialized to compact JSON so nothing is silently lost.
Everything runs entirely in your browser — your environment variables, which often include secrets, API keys, and database URLs, never leave your device or touch a server. That makes this safe to use with real configuration, unlike tools that post your input somewhere to process it. Paste, convert, copy, done.
When to use .env ↔ JSON
- Seeding CI/CD secrets
Turn a local .env into JSON to paste into a CI provider or secret manager that expects JSON.
- Serverless config
Convert JSON environment blocks from a platform back into a .env file for local development.
- Auditing variables
View a messy .env as clean, structured JSON to spot duplicates, typos, or stray comments.
- Migrating between tools
Move configuration between systems that disagree on whether they want .env or JSON.
Frequently asked questions
Does it handle quotes and escaped characters?+
Yes. Double-quoted values are unescaped (\n, \t, \", \\), single-quoted values are kept literal, and quoting is re-applied automatically when converting back so values round-trip correctly.
Are comments and the export prefix handled?+
Yes. Full-line and inline # comments are ignored, and an optional "export " prefix on each line is stripped. A # inside a quoted value is preserved as part of the value.
What happens to nested objects in JSON → .env?+
A .env file is flat, so nested objects and arrays are serialized to compact JSON and stored as the value of their key. Top-level scalar values convert directly.
Are my environment variables uploaded anywhere?+
No. Conversion runs entirely in your browser, so secrets, API keys, and database URLs in your .env never leave your device. Nothing is sent to a server.
Why are all the JSON values strings?+
Environment variables are always strings by definition — there are no numbers or booleans in a .env file — so the JSON output represents every value as a string to stay accurate.
Related tools
Format, beautify, and validate JSON online. Free, fast, runs entirely in your browser.
Validate JSON syntax online with clear error messages and line numbers. Free and private.
Convert JSON to a Zod schema instantly. Infers email, UUID, URL, and datetime formats, merges array shapes with .optional(), and outputs Zod v4 or v3 code. Free, browser-only.
From the blog
A JWS (signed JWT) has 3 parts; a JWE (encrypted JWT) has 5. Learn what each JOSE acronym means, when a token is signed vs encrypted, and which you need.
RFC 7519 defines 7 registered JWT claims: iss, sub, aud, exp, nbf, iat, jti. Learn what each means, how to validate it, and the checks that stop attacks.