๐ง .env File Parser
Parse the contents of a .env file (KEY=VALUE format) into a list of key-value pairs, or convert it to JSON. Duplicate keys are flagged with a warning. Everything runs entirely in your browser.
How to use
- Paste the contents of your .env file into the input box.
- The parsed key-value pairs are listed automatically.
- Copy the JSON-converted result with the "Copy" button.
How the calculation works
A .env file holds an application's settings and secrets as KEY=VALUE, one per line. This tool reads each line according to these rules: Blank lines and lines starting with "#" are ignored as comments. A leading "export " is removed (for .env files written to double as shell scripts). Keys start with a letter or underscore and contain only letters, digits and underscores. Whitespace around "=" is ignored, and double or single quotes wrapping a value are removed. If a key appears more than once, a duplicate warning is shown, and the JSON output uses the last value โ the usual behaviour when a .env file is loaded.
Worked example
Reading this .env # example export API_URL=https://example.com DEBUG=true SECRET_KEY="abc123" DEBUG=false JSON output {"API_URL": "https://example.com", "DEBUG": "false", "SECRET_KEY": "abc123"} DEBUG is defined twice, so a duplicate warning appears and the later false wins. All values are strings, so true becomes the string "true".
Things to be aware of
- A "#" in the middle of a line is not treated as a comment: "KEY=value # note" gives the value "value # note".
- Escapes inside quotes (such as "\n") and variable expansion (such as ${OTHER_KEY}) are not processed.
- All values are strings; nothing is converted to numbers or booleans.
- .env files often hold secrets, so be careful when sharing them. This tool's processing stays in your browser.
FAQ
How are comment lines (starting with #) handled?
Lines starting with # are ignored and not parsed.
What if a value is wrapped in single or double quotes?
The surrounding quote characters are stripped automatically, leaving just the inner string as the value.
What happens if the same key is defined more than once?
Duplicate keys are flagged with a warning marker. In the JSON output, the later-defined value wins โ matching how a typical .env loader behaves.