https://github.com/hxhieu/json-to-env
CLI tool to convert the JSON format to .env format
https://github.com/hxhieu/json-to-env
appsettings appsettings-json appsettingsjson asp-net-core aspnetcore env environment environment-variables go golang json
Last synced: 5 months ago
JSON representation
CLI tool to convert the JSON format to .env format
- Host: GitHub
- URL: https://github.com/hxhieu/json-to-env
- Owner: hxhieu
- License: mit
- Created: 2022-01-18T04:00:19.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-01-18T05:51:18.000Z (over 4 years ago)
- Last Synced: 2025-10-14T14:43:34.448Z (8 months ago)
- Topics: appsettings, appsettings-json, appsettingsjson, asp-net-core, aspnetcore, env, environment, environment-variables, go, golang, json
- Language: Go
- Homepage:
- Size: 33.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Download
Download from the [Releases](https://github.com/hxhieu/json-to-env/releases/latest)
OR
```
go install github.com/hxhieu/json-to-env@latest
```
# Usage
```
Convert the JSON format to .env format
Usage:
json-to-env [flags]
Flags:
-h, --help help for json-to-env
-o, --output string The output file (default ".env")
-s, --separator string The nested fields separator (default "__")
```
# Example
```
// appsettings.json
{
"Logging": {
"LogLevel": {
"Default": "Debug",
"Microsoft": "Information",
"System": "Information",
"Microsoft.EntityFrameworkCore.Database.Command": "Warning"
},
"UseDeveloperExceptionPage": "true"
}
}
```
Output as
```
# .env
Logging__UseDeveloperExceptionPage="true"
Logging__LogLevel__Default="Debug"
Logging__LogLevel__Microsoft="Information"
Logging__LogLevel__System="Information"
Logging__LogLevel__Microsoft_EntityFrameworkCore_Database_Command="Warning"
```
# Known issues
- JSON unmarshall fields ordering are not preserved
- JSON comments `//` and `/* */` are not supported so remove them in prior
- `:` as separator will cause weird output