All Tools View Categories About Contact Privacy

.env to Windows Batch Converter

Convert a .env file into a Windows batch script of set "KEY=value" lines — percent-safe, CRLF, echo off.

Runs entirely in your browser — nothing is uploaded.

About .env to Windows Batch Converter

Windows batch files are a stubborn survivor of every modernization effort. Scheduled tasks, legacy services and on-prem tooling still consume environment configuration as set KEY=value lines — and batch is unforgiving about them. A literal % in a value must be doubled to %% or cmd will try to expand it; a stray & acts as a command separator; and a file saved with the wrong line endings misbehaves under cmd.

The .env to Windows Batch Converter generates a correct batch file. Every variable becomes set "KEY=value" in the quoted form cmd parses safely, percent signs are doubled automatically, keys are validated against batch naming rules, and the file is written with CRLF line endings and an @echo off header.

The result is deterministic and reviewable — read the output before running it, then call env.bat from your scripts or the scheduler. And as always, everything happens in your browser.

Features

  • Correct SET lines: set "KEY=value" quoted form for batch.
  • Percent doubling: every % becomes %% so values stay literal.
  • CRLF endings: proper Windows line terminators.
  • @echo off header: clean output when the script runs.
  • Comment control: keep .env comments as @rem lines or drop them.
  • Key validation: valid batch names; duplicates flagged.
  • Copy or download: clipboard or an env.bat file in one click.
  • Private: all conversion happens in your browser.

How to Use

  1. Paste your .env content into the input box, or load the sample.
  2. Toggle comment retention and whether to include the @echo off header.
  3. Click Convert. The batch file appears on the right.
  4. Review warnings and check the %-doubling in the sample.
  5. Download env.bat and call it from your scheduler or scripts.

Examples

Example 1 — Scheduled task. An admin generates an env.bat from the service .env and calls it at the top of the task script; the service inherits the exact variables.

Example 2 — Legacy on-prem service. A team maintaining a Windows service converts DATABASE_URL and retry counts into a batch fragment included by the service launcher.

Example 3 — CI on Windows agents. A pipeline copy of the sample runs cntos steps after the generated env.bat, keeping configuration inline and reviewable.

Example 4 — Init scripts. A sysadmin sources env.bat from a finalize.cmd to standardize machine-local config across Windows hosts.

Example 5 — Careful rollouts. A safety-conscious engineer reviews the doubled %% lines before deploying, confident the batch parser will read them verbatim.

Benefits

  • cmd-safe quoting: the set "..." form avoids separator traps.
  • Literal percents: %% doubling is automatic and correct.
  • Windows-native: CRLF endings and valid syntax.
  • Reviewable: deterministic output, valid keys.
  • Portable fragment: call it from any owning batch script.
  • Private & free: browser-only, no account.

Frequently Asked Questions

What does this tool do?
It reads a .env file and emits a Windows batch script where every KEY becomes a set "KEY=value" line. The output is CRLF-terminated, guarded by @echo off, and ready to run or call from another batch file.
When would I need a batch script?
Legacy infrastructure, job schedulers and on-prem services on Windows still rely on .bat files. When a .env has to configure one, this tool produces a correct batch file in one click instead of hand-escaping.
How is the % character handled?
In batch files a percent sign is an expansion marker, so literal percents must be written as %%. The tool automatically doubles every % in a value, which is exactly what cmd expects.
What about quotes and special characters?
By using set "KEY=value" form, characters like &, |, <, >, ^ and spaces are protected by cmd&apos;s quoted-string handling. The % sign still needs doubling, which the tool does.
Is my data uploaded?
No. Everything runs client-side in your browser. Nothing is sent to any server, stored or logged.
What are the key rules?
Keys must be letters, digits and underscores and must not start with a digit (cmd is sensitive to those starts). The tool validates keys and flags duplicates with line numbers.