Home › Developer Tools › ENV to JSON Converter

ENV to JSON Converter

Paste a .env file and get JSON or YAML instantly, or turn a JSON object into NAME=value lines. Quotes, export prefixes, comments, multi-line values and ${VAR} references are parsed the way dotenv reads them.

Last updated:

Your secrets stay on your device: parsing runs entirely in this tab and nothing is sent anywhere. Tip: Ctrl + Enter converts.

Advertisement
Advertisement

How to use the ENV to JSON Converter

  1. Pick a mode: .env → JSON, .env → YAML, or JSON → .env.
  2. Paste your file or drop it on the input. A sample .env is loaded to start.
  3. Choose options such as type conversion, ${VAR} expansion and nesting, or key style and quoting for .env output.
  4. Check the result; any syntax error is shown with its line and a Show in input button.
  5. Copy or download the converted file.

.env syntax at a glance

.env lineValue read
PORT=30003000 (string, or number with type conversion)
export DB_HOST=localhostlocalhost (export is ignored)
URL=https://x.io # notehttps://x.io
TAG=v1#betav1#beta (no space before #)
PASS='a$b#c'a$b#c (single quotes are literal)
MSG="Hi\nthere"Hi, line break, there
URL="db://${HOST}:5432"db://localhost:5432 with expansion
EMPTY=empty string

Good practice for .env files

  • Never commit secrets: keep .env in .gitignore and share a .env.example with placeholder values instead.
  • Quote anything with spaces or #: unquoted values end at an inline comment, so NAME=Ada # admin reads as just Ada.
  • Use names in UPPER_SNAKE_CASE: letters, digits and underscores only, not starting with a digit, so every shell and platform accepts them.
  • Remember everything is text: your app receives "false", not a boolean, so parse values explicitly in code.

Working with other config formats? Try the INI to JSON converter or turn JSON into YAML with JSON to YAML.

Frequently asked questions

Which .env syntax is supported?

The parser follows the rules of the popular dotenv libraries: NAME=value lines, an optional export prefix, # comment lines, inline comments after unquoted values (a # preceded by a space), single quotes for literal text, double quotes with \n, \t, \" and \\ escapes, backticks, and values in quotes that span several lines.

Are values converted to numbers and booleans?

Not by default, because environment variables are always strings. Tick Convert numbers & true/false to turn unquoted values like 3000 or false into JSON numbers and booleans. Quoted values always stay strings.

What does Expand ${VAR} references do?

It replaces ${NAME} and $NAME with the value of a variable defined earlier in the same file, like dotenv-expand. ${NAME:-default} uses the default when NAME is unset or empty. Single-quoted values and \$ are never expanded. Variables from your real system environment are not used.

What does Nest keys on __ do?

Keys with a double underscore, such as REDIS__HOST and REDIS__PORT, become a nested object {"REDIS": {"HOST": …, "PORT": …}}. This is the convention ASP.NET Core and several config libraries use to map environment variables to nested settings.

How is JSON converted to a .env file?

Each top-level key becomes a variable. Nested objects are flattened by joining keys with the separator you choose (DB_HOST, DB__HOST or db.host), names are upper-cased if you like, arrays become comma lists, JSON text or numbered variables, and values with spaces, # or quotes are quoted so they read back unchanged.

What happens with duplicate variables?

As in dotenv, the last definition wins. The tool tells you how many duplicates it found so you can clean up the file.

Is it safe to paste secrets?

Yes. The conversion runs in JavaScript inside this page; nothing is uploaded or stored on a server. You can even disconnect from the internet after the page loads.

Are all the tools on FreeToolCabin tested for quality and accuracy?

Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.

Related tools

INI to JSON ConverterConvert INI and CFG files to JSON and JSON back to INI, with sections, arrays and types.JSON to YAML ConverterConvert JSON to clean YAML as you type, with indent, quoting and sort options.Properties to YAML ConverterConvert Java .properties to nested YAML (application.yml) and YAML back to properties.JSON FormatterBeautify, minify and validate JSON, with a collapsible tree view.Docker Compose ValidatorCheck a docker-compose.yml for YAML errors, schema mistakes, broken references and deprecated keys.JSON to Excel ConverterTurn JSON into a styled .xlsx spreadsheet; nested arrays become their own linked sheets.JSON to CSVConvert JSON data to CSV for spreadsheets.CSV to JSONConvert CSV data to JSON with live preview.Excel to CSVConvert XLSX spreadsheets to CSV.CSV ViewerOpen a CSV or TSV file as a sortable, filterable table.Excel Viewer (XLSX / XLS)Open XLSX, XLS and ODS spreadsheets in your browser without Excel.Line Ending ConverterConvert text and files between CRLF, LF and CR line endings.Markdown to HTMLConvert Markdown to clean HTML with a live editor.XML to JSONConvert XML to JSON with validation.Text Encoding ConverterDetect and convert text file encodings like UTF-8, UTF-16 and Latin-1.JSON ViewerExplore JSON as a collapsible tree, search keys and values and copy any node's path.TTF to WOFF2 ConverterConvert TTF and OTF fonts to WOFF2 or WOFF and get a ready @font-face CSS snippet.Chmod CalculatorConvert Linux file permissions between checkboxes, octal (755) and symbolic (rwxr-xr-x) notation.JSON to TypeScriptGenerate TypeScript interfaces or types from JSON, with nested types and optional fields.Morse Code TranslatorTranslate text to Morse code and back, then play it as sound or a blinking light, or save a WAV.HTML Table GeneratorBuild HTML tables in an editable grid with styles, header rows, CSV import and live preview.Hex to Text ConverterConvert hex to text and text to hex with UTF-8 support and space, 0x, \x or comma formats.JSON to XML ConverterConvert JSON to well-formed XML with attributes, arrays and pretty print.YAML to JSON ConverterConvert YAML to pretty or minified JSON, with errors pinned to the exact line.HTML to Markdown ConverterTurn HTML or pasted rich text into clean Markdown with tables and live preview.Markdown Table GeneratorBuild Markdown tables in a grid or paste from Excel/CSV, with alignment and preview.JSON ValidatorCheck JSON with the exact line and column of each error, fix tips and one-click auto-fix.Image to Base64Convert images to Base64 data URIs, CSS backgrounds and HTML img tags in your browser.Base64 to ImagePaste a Base64 string or data URI to preview, identify and download the image.JSON CompareCompare two JSON documents and see every added, removed and changed path.Hex to DecimalConvert hex to decimal instantly with steps and signed mode.Decimal to HexConvert decimal to hex instantly with steps and signed mode.Binary to DecimalConvert binary to decimal instantly with steps and signed mode.Decimal to BinaryConvert decimal to binary instantly with steps and signed mode.Two's Complement CalculatorDecimal to two's complement binary and back for 4-64 bits, with invert-and-add-1 steps.XML to CSV ConverterConvert XML to CSV: detects repeating records, flattens nested data, pick your columns.CSV to XML ConverterConvert CSV to well-formed XML with custom root and row names, escaping and pretty print.TOML to JSON ConverterConvert TOML to JSON and JSON to TOML with a full v1.0 parser and clear error lines.ISBN Converter & ValidatorConvert ISBN-10 to ISBN-13 and back, validate check digits and hyphenate, one or in bulk.JSON Flatten / UnflattenFlatten nested JSON to dot or bracket path keys, or unflatten flat keys back to nested JSON.JSON to Dart ClassTurn JSON into Dart model classes with fromJson, toJson, null safety and nested classes.JSON to Java ClassTurn JSON into Java POJOs or records with Lombok, getters/setters and Jackson or Gson annotations.JSON to Kotlin Data ClassTurn JSON into Kotlin data classes for kotlinx.serialization, Gson, Moshi or Jackson.JSON to Markdown TableTurn a JSON array of objects into a GitHub Markdown table with column picker and alignment.JSON to PHP ArrayConvert JSON to PHP array code (short [] or array()) and PHP arrays back to JSON.JSON to Rust StructTurn JSON into Rust structs with serde derives, rename attributes, Option and Vec types.JSON to SQL ConverterConvert a JSON array of objects to CREATE TABLE and INSERT statements for MySQL, Postgres, SQLite.JSON to Swift StructTurn JSON into Swift Codable structs with CodingKeys, optionals and nested types.JSON to TOML ConverterConvert JSON to clean TOML with tables, arrays of tables, inline tables and dates.JSONL to JSON ConverterConvert JSON Lines / NDJSON to a JSON array and back, with line-level error reports.PX to EM ConverterConvert pixels to em using the parent font size, and em back to px, with conversion tables.Query String to JSONConvert URL query strings to JSON with nested brackets and arrays, and JSON back to a query string.REM to PX ConverterConvert CSS rem values to pixels for any root font size, with a quick 0.25–6rem table.SQL to JSON ConverterConvert SQL INSERT statements and dumps into a JSON array of row objects, with CSV export.TSV to CSV ConverterConvert TSV to CSV and back, or between tab, comma, semicolon and pipe, with correct quoting.TypeScript to JavaScriptConvert TypeScript or TSX to clean JavaScript instantly: strip types, keep or compile JSX.XML to YAML ConverterConvert XML to clean YAML with attributes, text nodes, lists and exact error lines.YAML to XML ConverterConvert YAML to pretty, well-formed XML with custom root, attributes and array item tags.Boolean Algebra SimplifierSimplify boolean expressions or minterm lists to minimal SOP and POS with Quine-McCluskey steps.Compare Excel FilesCompare two Excel spreadsheets cell by cell, highlight changes and export a diff report.CSV CleanerClean messy CSV in one click: trim spaces, drop empty rows and columns, fix headers, dedupe.CSV VLOOKUP ToolJoin two CSV or Excel files on a key column like VLOOKUP, with left, inner and full joins.Remove Duplicates in ExcelFind and remove or highlight duplicate rows in XLSX or CSV files by the columns you choose.GeoJSON ViewerView GeoJSON on a map, inspect and edit properties, validate against RFC 7946 and export.GPX ViewerOpen GPX tracks on a map with distance, elevation profile, moving time, speed and splits.JSON Repair ToolFix broken JSON automatically: trailing commas, quotes, comments, truncated data, with a diff.Karnaugh Map SolverSolve 2–6 variable K-maps: click cells or enter minterms to get the minimal SOP or POS with groups.Merge Excel FilesCombine XLSX, XLS and CSV files into one workbook or append all rows into a single sheet.
See all 129 Data & File Format Converters →