Skip to content

Main content

Restricted Dotenv Assignment Line Formatter

Format one portable environment assignment using the documented literal JSON-double dotenv subset; never expands dollar references or emits a shell command.

Loading tool…

Description

Format one portable environment assignment using the documented literal JSON-double dotenv subset; never expands dollar references or emits a shell command.

Environment assignments pair names with literal string values. Repeated names need an explicit first/last policy, and missing values differ from present empty strings. A dotenv file and a shell program can use different quoting and expansion rules; these tools implement their stated literal subsets using supplied data.

Format one portable environment assignment using the documented literal JSON-double dotenv subset; never expands dollar references or emits a shell command.

When to use this tool

Use this tool to format one portable environment assignment using the documented literal JSON-double dotenv subset; never expands dollar references or emits a shell command.

How to use the tool and how it works

  1. Enter name, value using the input definitions below.
  2. Run the operation. Resolve malformed-input errors before interpreting the result.
  3. Read result.line. Interpret signs, units, ordering and null values using the rules below.

Validate the portable ASCII assignment name and NUL-free literal value, serialize the value with JSON string escaping, and join name + equals + quoted value.1

Input fieldMeaning and unitsAccepted input
namePortable ASCII name matching [A-Za-z_][A-Za-z0-9_]*.Text, at most 8,192 UTF-16 code units; the stated grammar and narrower limits also apply.
valueLiteral string value to encode; NUL is rejected where stated.Text, at most 8,192 UTF-16 code units; the stated grammar and narrower limits also apply.
Output fieldInterpretation
resultObject containing the fields below.
result.lineFormatted assignment line without a terminal newline.
json
{
  "input": {
    "name": "A",
    "value": "x\ny"
  },
  "output": {
    "result": {
      "line": "A=\"x\\ny\""
    }
  }
}

Limitations and assumptions

  • The result is one line in the documented JSON-double dotenv subset, without shell interpolation or a terminal newline.
  • Portable assignment records require names matching [A-Za-z_][A-Za-z0-9_]* and NUL-free values. Name matching is case-sensitive. Reference scanners and quoted-value helpers follow only their own stated grammar and do not read the process environment.
  • Every declared top-level input is required and unknown fields are rejected. Ordinary strings are limited to 8,192 UTF-16 code units and lists to 128 entries, with tighter operation-specific bounds where stated. JSON text has bounded nesting and node counts.
  • Numeric outputs must be finite and within the absolute safe-integer magnitude; exact larger integers use decimal text. Source positions are zero-based UTF-16 offsets and span ends are exclusive unless a different convention is explicitly stated.

Alternative or Complementary methods

Select the consuming application’s dotenv dialect explicitly. Keep literal substitution separate from recursive expansion and shell execution, and retain occurrence provenance when resolving duplicate assignments.

References

  1. Tool behavior and example: Restricted Dotenv Assignment Line Formatter — tool.io

Similar or alternative tools

  • Restricted Dotenv Unquoted Line Tokenizer

    Tokenize a restricted unquoted dotenv assignment with portable ASCII name and comments beginning at start or after whitespace; rejects quoting, interpolation and multiline syntax.

  • Environment Empty Value Audit

    Distinguish empty from nonempty whitespace-only portable environment values, retaining source occurrences; does not conflate missing variables with present empty values.