⌘ Config & DevOps

appsettings.json ↔ Environment Variables

Flatten ASP.NET Core appsettings.json into Section__Key environment variables for .env, Docker Compose, Kubernetes, Azure App Service, PowerShell, and bash — or rebuild the JSON from env vars.

Double-underscore keys 8 output formats Reverse mode Comments allowed

Loading appsettings ↔ Env…

What this page sends

  • Your input: The JSON is converted in this tab and not sent to a server. The Share button switches itself off while the input contains secret-looking values.
  • Share links: Share links put a Base64 copy of your input and output in the URL itself (after #d=). Anyone with the link can read it, so don't share a link that contains secrets.
  • Editor: On desktop screens the code editor (Monaco) is downloaded from cdn.jsdelivr.net; phones get a built-in lightweight editor instead.
  • Page load: Loading the page requests HTML, scripts and images from ByteKiln, fonts from Google Fonts, and sends Google Analytics page views, tool-usage events and catalog interactions (tool/category IDs, result status and whether a click followed search — never your input, output or search terms). Privacy & sharing

How the appsettings.json ↔ Environment Variables Works

ASP.NET Core reads configuration from several providers — appsettings.json, appsettings.{Environment}.json, user secrets, environment variables, command-line arguments — and later providers override earlier ones. That override order is why environment variables are the standard way to change a setting per container, per pod, or per App Service slot without rebuilding the image. The catch is the naming: every nested JSON key has to be flattened into one variable name, arrays need index segments, and the separator has to be __ on Linux because a colon is not a legal character in most shells. Doing that by hand for a 60-line appsettings.json is slow and easy to get wrong, especially the quoting — a connection string with a semicolon breaks an unquoted bash export, a dollar sign gets interpolated by Docker Compose, and $(…) gets expanded by Kubernetes. This converter applies the same flattening rules as Microsoft.Extensions.Configuration, then quotes each value correctly for the target you pick. It also works in reverse: paste the environment block from a Compose file, a Kubernetes manifest, Azure's Advanced edit JSON or a shell history, and it rebuilds the nested appsettings.json so you can see what a running container is actually configured with.

Flattening, exactly like .NET

The input is parsed with a JSON reader that accepts // and /* */ comments and trailing commas, as .NET's JSON configuration provider does. Objects become Section:Key paths, array elements become Section:0, Section:1, and the path is joined with __ (or : for the colon output). Numbers keep their original text, so 1.0 stays 1.0 and a 19-digit ID is not rounded.

Quoting per target

bash uses single quotes with ' written as '\''. PowerShell uses verbatim single-quoted strings and doubles both straight and curly quotes, which PowerShell also treats as delimiters. Docker Compose values are YAML double-quoted with $ escaped as $$. Kubernetes escapes $( as $$( so the kubelet does not expand it. .env values stay unquoted when safe and are single- or double-quoted otherwise.

Warnings instead of silent changes

Empty objects and arrays, null values, keys that already contain __ or :, and keys that collide when compared case-insensitively are all reported, because each of them changes what .NET will see. Names that bash cannot export — for example Microsoft.AspNetCore with its dots — are commented out in the bash output rather than emitted broken.

Reverse mode

Each input style is parsed with its own quoting rules: dotenv escapes, bash quoting, PowerShell backtick escapes, YAML scalars in Compose and Kubernetes lists, and Azure's JSON array. Names are split on __ and :, merged case-insensitively as .NET does, and rebuilt into nested JSON. Optional type inference writes true, false and numbers as JSON literals.

Limitations

  • It converts one JSON file at a time. It doesn't layer appsettings.{Environment}.json, user secrets or command-line arguments the way the configuration builder does, so the result is what this file contributes, not your app's final configuration.
  • Values are written as strings, as environment variables are; the tool can't know whether your options class binds "8080" to an int.
  • Comments in the JSON are accepted but not carried into the output.
  • Secret-looking values are detected by key name. A connection string under an unusual name won't switch off the Share button.

FAQ

Short answers for the things developers usually ask before trusting a tool.

Is my appsettings.json uploaded anywhere?

No. Parsing and conversion run in your browser with JavaScript; nothing you paste is sent to a server. Because appsettings files often hold connection strings and keys, the Share button is switched off whenever the input contains secret-looking values.

Why does ASP.NET Core use a double underscore (__) in environment variable names?

Configuration keys are hierarchical and use a colon as the separator (Logging:LogLevel:Default), but most Linux shells and container runtimes reject a colon in a variable name. The environment variable provider in Microsoft.Extensions.Configuration replaces __ with : when it reads variables, so Logging__LogLevel__Default works on every platform.

How are arrays like AllowedHosts converted?

Each element gets its index as a key segment: AllowedHosts__0=a.com and AllowedHosts__1=b.com. Arrays of objects nest further, for example Downstream__0__BaseUrl. When converting back, keys become a JSON array only if the indexes run 0, 1, 2… without gaps; otherwise they stay an object and the tool warns you.

What happens to null values, numbers and booleans?

Environment variables are always strings. Numbers and booleans are written as their JSON text (50, true), and .NET converts them back when it binds options. A null becomes an empty value, which .NET reads as an empty string rather than null. Empty objects and arrays produce no variables at all, and the tool lists the paths it dropped.

How does the prefix option relate to AddEnvironmentVariables("MYAPP_")?

When you call AddEnvironmentVariables with a prefix, .NET only reads variables that start with it (matched case-insensitively) and strips the prefix before mapping __ to :. Enter the same prefix here and every generated name starts with it; in reverse mode, variables without the prefix are skipped and listed.

Can I use colons instead of double underscores?

On Windows and in launchSettings.json, yes — the "Colon keys" output uses Section:Key. On Linux, in Docker and in Kubernetes, stick with __, because a colon is not a valid character in most shells' variable names.

Why does the tool warn about keys that differ only by case?

.NET configuration keys are case-insensitive. Two JSON keys such as Logging and logging in the same object make the JSON provider throw "A duplicate key was found" at startup, and as Linux environment variables both names can exist at once while .NET silently keeps only one of them.

Related tools

Useful follow-ups when one conversion usually turns into three more.

Want the background and worked examples? There's a longer write-up.

Read the appsettings ↔ Env guide