# .env stringify

`env-stringify` · version 1.0.0 · Versions & config · free, no key needed

Serialize unique env key/value entries to a canonical dotenv-subset document.

**Use when you need to: env stringify · serialize env entries · stringify dotenv subset.**

## Supported

- env stringify
- serialize env entries
- stringify dotenv subset

## Not supported

- preserve comments
- single-quoted output
- variable expansion
- export prefix
- read files

## Behavior

- entries is an array of at most 5000 objects { key, value } with unique keys matching [A-Za-z_][A-Za-z0-9_]*.
- Each value is a string of at most 64 KiB UTF-8. Values containing CR are rejected.
- A value is emitted unquoted iff it matches ^[A-Za-z0-9_./:-]*$, including the empty string as KEY=.
- Otherwise the value is double-quoted and \, ", LF, and TAB are escaped as \\ \" \n \t.
- Lines are joined with LF. A non-empty document ends with a trailing LF. Empty entries yield empty text.
- Serialized UTF-8 text must not exceed 250 KiB.

## Input

- `entries` (array of object, required): max items 5000

## Output

- `text` (string, required): max length 256000

## Limits

- max entries: 5000
- max value bytes: 65536
- max output bytes: 256000

## Example

Request input:

```json
{
  "entries": [
    {
      "key": "HOST",
      "value": "localhost"
    },
    {
      "key": "NAME",
      "value": "Ada Lovelace"
    },
    {
      "key": "NOTE",
      "value": "say \"hi\"\nnow"
    },
    {
      "key": "EMPTY",
      "value": ""
    },
    {
      "key": "TAB",
      "value": "a\tb"
    }
  ]
}
```

Response:

```json
{
  "result": {
    "text": "HOST=localhost\nNAME=\"Ada Lovelace\"\nNOTE=\"say \\\"hi\\\"\\nnow\"\nEMPTY=\nTAB=\"a\\tb\"\n"
  }
}
```

## How to call it

### MCP

Connect `https://computefirst.net/mcp` ([setup](/docs#connect)), then call `execute` with:

```json
{
  "id": "env-stringify",
  "version": "1.0.0",
  "input": {
    "entries": [
      {
        "key": "HOST",
        "value": "localhost"
      },
      {
        "key": "NAME",
        "value": "Ada Lovelace"
      },
      {
        "key": "NOTE",
        "value": "say \"hi\"\nnow"
      },
      {
        "key": "EMPTY",
        "value": ""
      },
      {
        "key": "TAB",
        "value": "a\tb"
      }
    ]
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/env-stringify/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"entries":[{"key":"HOST","value":"localhost"},{"key":"NAME","value":"Ada Lovelace"},{"key":"NOTE","value":"say \"hi\"\nnow"},{"key":"EMPTY","value":""},{"key":"TAB","value":"a\tb"}]}'
```

The machine-readable contract is at [/v1/tools/env-stringify/versions/1.0.0](/v1/tools/env-stringify/versions/1.0.0).

### CLI

```sh
node cli.mjs run env-stringify 1.0.0 --input input.json --base-url https://computefirst.net
```

Get the client at [/clients/cli/](/clients/cli/).

## Related tools

- [.env parse](/tools/env-parse): Parse a strict dotenv-subset document into ordered key/value entries.
- [.env merge](/tools/env-merge): Overlay two dotenv-subset documents, replacing left values and appending right-only keys.
- [SemVer compare](/tools/semver-compare): Compare two strict Semantic Versions by precedence.
- [SemVer filter](/tools/semver-filter): Filter strict versions that satisfy a range, preserving original order and strings.
- [SemVer satisfies](/tools/semver-satisfies): Test whether a strict version satisfies a semver range.
- [SemVer sort](/tools/semver-sort): Sort strict valid Semantic Versions in ascending precedence order.
