Flatten a JSON object into UPPER_SNAKE KEY=value lines. Part of the DevTools Surf developer suite. Browse more tools in the Converters collection.
Use Cases
DevOps engineers converting JSON config exports into .env file format
Developers bootstrapping local environment files from JSON API config responses
Platform teams transforming JSON secrets manager output into env var format
Backend developers migrating configuration from JSON files to environment variables
Tips
Paste a JSON object to get UPPER_SNAKE_CASE key=value .env output
Nested objects are flattened with underscore-separated key paths
Copy the output directly into a .env file for local development
Fun Facts
The .env file convention was popularized by the Twelve-Factor App methodology (2011), which recommended storing config in environment variables, not code.
The dotenv library for Node.js, created by Scott Motte in 2013, has over 35 million weekly npm downloads — it's one of the most depended-on packages in the ecosystem.
Environment variables have been part of Unix since Version 7 (1979). The convention of UPPER_SNAKE_CASE for env vars comes from C preprocessor macro naming conventions.
FAQ
How does it flatten nested objects?
Dot-path keys get joined with underscore and uppercased. `{db: {host: "x"}}` becomes `DB_HOST=x`. Arrays use index suffixes (`ITEMS_0_NAME`).
What about special characters in values?
Values containing spaces, quotes, or dollar signs are quoted. The output parses correctly in any dotenv-compatible loader.
Are comments added?
Optional — toggle 'add original key as comment' to emit `# user.address.city` before each flattened line. Useful for human readers.
Can I go back from .env to JSON?
Yes — env-to-json rebuilds the nested structure. Pair the two for bidirectional conversion.