Converters

.env ⇄ JSON Converter

Convert a .env file to JSON or JSON back to .env format. The parser handles quoted values, comments, the export prefix, inline comments on unquoted values, and escape sequences in double-quoted strings. This is useful for migrating environment variables between formats or inspecting what a .env file actually contains.

.env ⇄ JSON — Convert between dotenv files and JSON objects

What it does

  • Parses .env files into a JSON object with key-value pairs
  • Handles double-quoted values with escape sequences (\n, \t, \")
  • Handles single-quoted values (preserved literally, no escapes)
  • Strips inline comments on unquoted values (KEY=value # comment)
  • Supports the export prefix (export KEY=value)
  • Converts JSON back to .env format with proper quoting

Use cases

  • Converting a .env file to JSON for use in a JavaScript application
  • Migrating environment variables from .env to a JSON config file
  • Inspecting the actual key-value pairs in a .env file with comments stripped
  • Generating a .env file from structured JSON data

How it works

1

Paste your .env content or JSON into the input pane

2

Choose .env → JSON or JSON → .env direction

3

The tool parses and converts, handling quotes and comments

4

Copy the result for use in your application or config file

Frequently asked questions

1How does it handle comments?

Lines starting with # are treated as comments and skipped. For unquoted values, inline comments (KEY=value # comment) are stripped — everything after the # is removed. Quoted values preserve # as part of the value.

2What's the difference between single and double quotes?

Double-quoted values process escape sequences (\n becomes a newline, \t becomes a tab). Single-quoted values are preserved literally — no escape processing. This matches the behavior of most .env parsers.

3Does it handle the export prefix?

Yes. Lines like export KEY=value are parsed correctly — the export prefix is stripped and KEY=value is extracted. This is common in shell scripts and some .env implementations.

Related tools

Use .env ⇄ JSON offline in Devinity

All 95 tools run locally on your Mac. No internet required, no data sent to servers.

Download Devinity →