ENV to JSON Converter
Parse .env files into clean JSON — quotes, comments and multiline handled.
.env input
JSON output
No JSON yet
Paste a .env file or load an example.
Examples
Standard dotenv
PORT=3000
DEBUG=true
URL="postgres://db/app"{"PORT":"3000","DEBUG":"true","URL":"postgres://db/app"}Values stay strings by default; switch on type inference for a number and boolean.
Literal single quotes
BASE=/app
A='${BASE}/x'{"BASE":"/app","A":"${BASE}/x"}Single-quoted values never interpolate, even when the option is enabled.
Skipped line
A=1
NO SEPARATOR
B=2{"A":"1","B":"2"}A diagnostic points at line 2 so you can fix the source without losing the valid entries.
About this tool
Turning a .env file into JSON sounds like a one-line regex until quotes, comments and multiline values appear. This converter implements the de-facto dotenv grammar: double-quoted values process escapes, single-quoted values stay literal, comments are recognized only outside quotes, and export prefixes are stripped before parsing.
A real quoted value can span lines; newlines become part of the JSON string. BOM and CRLF are normalized, empty values stay empty strings, and invalid keys or lines without a separator are skipped with diagnostics rather than silently corrupting the output. Duplicate keys follow a selectable last-wins or first-wins policy, with every override reported.
Optional interpolation resolves ${VAR} references against already-parsed values, up to a fixed pass count. Unresolved names stay literal with a warning, self-references are detected, and single-quoted values are deliberately left alone. Type inference is off by default because env values are strings by contract; when enabled it converts only exact booleans and strictly formatted numbers, so 007 remains a string.
Because env files routinely contain credentials, everything runs in this browser tab: no upload, no logging, no storage. Copy or download the JSON only when you are ready.
What this tool does not do
- Supports the common dotenv grammar rather than every dialect extension (no ${VAR:-default} or backtick-quoted values).
- Interpolation resolves against parsed values only; process.env is never consulted.
- Type inference is deliberately strict and off by default to avoid corrupting identifiers.
- The tool never stores input; refreshing the page clears pasted secrets.
How to use this tool
Paste a .env file
Paste or type your dotenv content, or load the standard, quotes or unclosed-quote example.
Choose policies
Select duplicate handling and pretty or minified output; optionally enable interpolation and type inference.
Review notices
Interpolation cycles, unresolved variables and skipped lines appear under the output with their line numbers.
Copy the JSON
Copy the object or download it as env.json for use in tests or config loaders.
Use cases
Seeding process.env fixtures
Turn a real .env into a JSON fixture for tests without hand-editing quotes and comments.
Migrating compose configuration
Move env blocks into JSON-backed configuration stores or typed loaders while seeing every parse decision.
Auditing env files
Use diagnostics and duplicate warnings to find malformed lines and conflicting keys before a deployment.
Value handling
| Input | JSON value |
|---|---|
| A=1 | "1" (or 1 with type inference) |
| A="hello # world" | "hello # world" — hash is data |
| A='C:\path' | "C:\\path" — no escapes in single quotes |
| A="line1\nline2" | "line1\nline2" with a real newline |
| export A=1 | "1" — prefix stripped |
| A=${BASE}/bin | Resolved when interpolation is on, otherwise literal |
A bare $VAR without braces is not interpolated; use ${VAR} explicitly.
Common mistakes
Mistake:Expecting type inference to coerce leading-zero values.
Fix:The strict numeric regex leaves 007 and similar identifiers as strings. Enable inference only when you want unambiguous numbers and booleans.
Mistake:Using bare $VAR in interpolation.
Fix:Only ${VAR} references are resolved. The braces make the boundary explicit and avoid rewriting passwords that contain dollar signs.
Mistake:Leaving a quote unclosed while composing a multiline value.
Fix:The parser continues across lines, and an unclosed value at end of input is reported with its start line rather than silently discarded.
Frequently asked questions
How are quoted values handled?
Double quotes process escapes such as \n, \t, \" and \\; single quotes are literal, so backslashes and ${VAR} text are preserved exactly. A # inside quotes is data, never a comment, and an export prefix is stripped before the key is read.
Does it support multiline values?
Yes. A double-quoted value continues across lines and real newlines are preserved in the JSON string. If the closing quote never appears, the tool reports the start line and keeps the collected text so you can repair it.
What happens to comments?
Full-line comments are skipped. For unquoted values, a # preceded by whitespace starts an inline comment and is removed. Comments inside quotes are preserved as part of the value.
Are variables interpolated?
Only when you enable the option, and only in the ${VAR} form. References resolve against earlier parsed values; unresolved names and self-references stay literal and produce a warning. Single-quoted values are never interpolated.
Is my .env uploaded anywhere?
No. Parsing and conversion run in this browser tab with no network request, no logging and no storage. Because env files contain secrets, use a sanitized sample on shared machines and clear the page when finished.
References & standards
Related tools
Base32 Encoder / Decoder
Encode and decode Base32 (RFC 4648) with hex input mode and Crockford variant. Handles TOTP secrets. Runs in-browser.
Base58 Encoder / Decoder
Convert hex or text to Base58 and back, with Base58Check validation (version byte + checksum). IPFS CIDs too. In-browser.
Base64 Toolbox
Professional Base64 workspace for text, files and images with Base64URL, MIME, Data URI, strict validation, image preview and ready-to-use snippets.
BibTeX to JSON Converter
Parse .bib bibliographies into structured JSON with authors, months, macros and LaTeX cleanup, all in-browser.
C# to VB.NET Converter
Convert a subset of C# — classes, methods, variables, loops — into VB.NET
CSV Data Viewer
Paste CSV and inspect it as a sortable, searchable table with delimiter detection and inline export.