What is JSON to Dotenv Converter?
JSON (JavaScript Object Notation) is a widely used data format for structured configuration, while .env (dotenv) files store environment variables in flat KEY=VALUE format. This tool converts between the two formats: flatten nested JSON objects into .env files with UPPER_SNAKE_CASE keys, or reconstruct nested JSON from .env files. It handles nested objects using underscore-separated keys and arrays using index notation.
How to Use
- Choose the conversion direction using the toggle button (JSON → .env or .env → JSON)
- Paste your JSON or .env content in the input area
- Click 'Convert' to generate the output
- Copy the result and use it in your project
Why Use This Tool?
Tips & Best Practices
- Nested keys are joined with underscores: {"database": {"host": "localhost"}} becomes DATABASE_HOST=localhost
- Arrays use index notation: {"ports": [80, 443]} becomes PORTS_0=80 and PORTS_1=443
- Values containing spaces or special characters are automatically quoted in .env output
Frequently Asked Questions
How are nested JSON objects handled?
Nested objects are flattened using underscore-separated keys. For example, {"database": {"host": "localhost"}} becomes DATABASE_HOST=localhost. All keys are converted to UPPER_SNAKE_CASE to follow environment variable naming conventions.
How are arrays converted?
Arrays use index notation. For example, {"ports": [80, 443]} becomes PORTS_0=80 and PORTS_1=443. If array items are objects, they are further flattened with the index as part of the key prefix.
Can I convert .env back to JSON?
Yes. Use the direction toggle to switch to '.env → JSON' mode. The tool will parse KEY=VALUE pairs and attempt to reconstruct nested objects from underscore-separated keys. Boolean, number, and null values are automatically detected.
Is my data secure?
Yes. All processing happens entirely in your browser. Your JSON and .env content is never sent to any server. No data is collected, stored, or transmitted. You can safely convert configs containing sensitive values like API keys and database passwords.
What value types are supported?
The tool handles strings, numbers, booleans, and null values. In JSON → .env mode, all values are converted to their string representation. In .env → JSON mode, the tool auto-detects booleans (true/false), numbers, and null values and converts them to their proper JSON types.