YAML to Bash Converter — Free Online
YAML to Bash Exports Converter
Paste YAML and get a block of export statements you can source in a shell script, a Dockerfile RUN step or a CI job. Conversion runs in your browser; nothing is uploaded.
How the conversion works
- Each setting becomes
export NAME='value'. - Nested keys are joined with underscores and uppercased:
app.portbecomesAPP_PORT. - List items get an index suffix —
DATABASE_REPLICAS_0,DATABASE_REPLICAS_1— because a name likeDATABASE_REPLICAS[0]is rejected byexport. - Values are single-quoted, so
$, backticks and spaces are taken literally and never expanded by the shell. A single quote inside a value is written safely as'\''. nullbecomes an empty string.- Names are valid identifiers (
my-appbecomesMY_APP), and colliding names are reported in a# warning:comment at the top. Dates,{}and[]are kept, never dropped. - The Options bar sets key case, separator, prefix, whether to write
export, and whether lists becomedeclare -a NAME=('a' 'b')arrays.
Example
app:
name: demo
port: 8080
database:
replicas: [db2, db3]becomes
export APP_NAME='demo'
export APP_PORT='8080'
export DATABASE_REPLICAS_0='db2'
export DATABASE_REPLICAS_1='db3'Using the output
# save the output as config.sh, then:
source ./config.sh
echo "$APP_NAME is on port $APP_PORT"Variables set with export are inherited by every program the script starts, which is how most tools read configuration.
.env or Bash exports?
Use the YAML to .env converter for files read by dotenv libraries, Docker --env-file or Compose. Use Bash exports when the file is sourced by a shell — dotenv files don't need export, and some dotenv loaders reject single-quoted values with escapes.
Related tools
- Bash properties to JSON — read variable assignments back into JSON
- YAML to .env
- YAML Validator