How to convert a .env file to JSON
Pick a direction — .env → JSON or JSON → .env — paste your file on the left, and the converted output appears live on the right. Going from .env to JSON gives you a flat object of string values, ready to drop into a config loader, a CI secret store that expects JSON, or a test fixture. Going the other way turns a JSON settings object into KEY=value lines you can save as a .env. The counters under each pane show how many variables were parsed, so you can confirm nothing was dropped.
The .env syntax it understands
The parser follows the conventions used by the popular dotenv libraries. Each variable is a KEY=value pair, one per line. Blank lines are ignored, and full-line comments beginning with # are skipped. A leading export — common when a file is meant to be sourced by a shell — is recognised and stripped, so export API_KEY=abc and API_KEY=abc are treated the same. Keys keep their original casing, and only the first = on a line splits the key from the value, so values may themselves contain equals signs without being mangled.
Quotes and escape sequences
Values can be bare or quoted, and the quoting style changes how they are read. Single-quoted values are taken literally — what is inside the quotes is exactly the value, with no escape processing — which is the safe choice for strings containing backslashes or dollar signs. Double-quoted values process escape sequences: \n becomes a newline, \t a tab, and \uXXXX a Unicode character, so multi-line secrets like a PEM key written on one line expand correctly. Unquoted values are read as-is, with a trailing inline comment (preceded by whitespace and a #) removed. Converting back, the tool re-quotes any value that needs it so the result re-parses to the same data.
Writing JSON back to .env
In JSON → .env mode, paste a flat JSON object. Each property becomes a line: strings are written directly, or wrapped in double quotes and escaped when they contain spaces, newlines, quotes or a #; numbers and booleans are written as their literal text; null becomes an empty value; and nested objects or arrays are serialized to compact JSON inside double quotes so structured config survives the round-trip. If the JSON does not parse, the status line points out the error.
Why convert secrets locally
A .env file is, almost by definition, a list of secrets — database passwords, API tokens, signing keys, third-party credentials. Pasting one into an online converter or an AI chatbot hands those secrets to a server you do not control, where they may be logged or retained. This tool never makes a network request: it parses and rebuilds your file entirely in the browser tab, using deterministic rules that produce the same output every time. Use it on production credentials with confidence, work offline, and close the tab to leave no trace.
Frequently asked questions
- Does it handle quoted values and escapes?
- Yes — single quotes are literal, double quotes process
\n,\tand\uXXXX, and unquoted values drop trailing inline comments. - Are export prefixes and comments supported?
- Yes — a leading
exportis stripped,#comment lines and blank lines are skipped. - How are non-string JSON values written back?
- Numbers and booleans become literal text,
nullan empty value, and objects/arrays compact JSON in double quotes. - Is my .env file uploaded?
- No. It is processed entirely in your browser, so secrets never leave your device.