.env to JSON / JSON to .env

Convert between .env and JSON in both directions, handling quotes, inline comments, and values that contain both equals signs and hashes.

Single quotes are literal, while double quotes turn \n and \t into real newlines and tabs. Unquoted values only treat a hash preceded by whitespace as a comment, so a#b stays part of the value.

A repeated key keeps the last occurrence, matching dotenv behaviour; the page lists the duplicates.

Nesting splits on a double underscore by default, so DB__HOST becomes two levels. For keys like AWS_SECRET_ACCESS_KEY that use single underscores, leave the separator empty.

Comments

Sign in to join the discussion

No comments yet — be the first to say something