# REST File to cURL

Paste a .http, .rest or .ain request file, supply variables or an environment, and get ready-to-run curl commands for bash, cmd or PowerShell. Browser-only.

## Run it

- **CLI:** `gizza tool rest-file-to-curl '@host = https://api.example.com

### create item
POST {{host}}/v1/items HTTP/1.1
Content-Type: application/json
X-Trace-Id: {{trace_id}}

{"name":"gizza"}'`
- **Web:** https://gizza.ai/tools/rest-file-to-curl/
- **Agents:** machine-readable descriptor (parameters JSON Schema) at https://gizza.ai/tools/rest-file-to-curl/tool.json

## Inputs

- `data` — Request file (.http / .rest / .ain) _(field)_
- `env` — Variables (JSON object, named environments, or KEY=VALUE lines) _(field)_
- `environment` — Environment name (only when variables are named environments) _(field)_
- `request` — Which request (all, an index like 2, or a name) _(field)_
- `format` — File format _(field)_
- `shell` — Target shell _(field)_
- `flag_style` — Flag style _(field)_
- `multiline` — Wrap command over several lines _(field)_
- `unresolved` — Missing variables _(field)_
- `follow_redirects` — Follow redirects (-L) _(field)_
- `compressed` — Request a compressed response (--compressed) _(field)_
- `insecure` — Skip TLS verification (-k) _(field)_
- `include_comments` — Label each command with its request name _(field)_

## Output

- curl command (text)

## Query parameters

Open the tool pre-filled and auto-run via URL:

- `data` — Request file (.http / .rest / .ain)
- `env` — Variables (JSON object, named environments, or KEY=VALUE lines)
- `environment` — Environment name (only when variables are named environments)
- `request` — Which request (all, an index like 2, or a name)
- `format` — File format
- `shell` — Target shell
- `flag_style` — Flag style
- `multiline` — Wrap command over several lines
- `unresolved` — Missing variables
- `follow_redirects` — Follow redirects (-L)
- `compressed` — Request a compressed response (--compressed)
- `insecure` — Skip TLS verification (-k)
- `include_comments` — Label each command with its request name

Example: `https://gizza.ai/tools/rest-file-to-curl/?data=%40host%20%3D%20https%3A%2F%2Fapi.example.com%0A%0A%23%23%23%20create%20item%0APOST%20%7B%7Bhost%7D%7D%2Fv1%2Fitems%20HTTP%2F1.1%0AContent-Type%3A%20application%2Fjson%0AX-Trace-Id%3A%20%7B%7Btrace_id%7D%7D%0A%0A%7B%22name%22%3A%22gizza%22%7D&env=%7B%22host%22%3A%22https%3A%2F%2Fapi.example.com%22%2C%22trace_id%22%3A%22abc123%22%7D&environment=prod&request=all&format=auto&shell=bash&flag_style=short&multiline=true&unresolved=keep&follow_redirects=true&compressed=true&insecure=true&include_comments=true`

---

## About this tool

A **request file** is the plain-text format your editor's REST client uses — a
`.http` or `.rest` file in VS Code or IntelliJ, or an `.ain` template. It holds
one or more HTTP requests with `{{variables}}` standing in for the host, tokens
and IDs that change between environments. It is great inside the editor, and
useless the moment you need to hand the request to someone who doesn't use that
editor, drop it into a CI script, or paste it into a bug report.

This tool expands the file and prints the equivalent **curl** commands. Paste the
file, paste your variable values, and copy the result. Everything happens in your
browser — no file, URL, header or token is uploaded anywhere.

### What it understands

- **`.http` / `.rest` files** — a request line like `GET https://api.example.com/users HTTP/1.1`
  (the method is optional and defaults to `GET`, as does the `HTTP/1.1` suffix),
  header lines, a blank line, then the body.
- **Several requests in one file** — `###` separates them, and any text after the
  `###` becomes the request's name, as does a `# @name login` comment. Convert all
  of them at once, or pick one by name or 1-based index.
- **Comments** — lines starting with `#` or `//` are ignored.
- **File variables** — `@host = https://api.example.com` declares one, `{{host}}`
  uses it, and a variable may reference other variables recursively.
- **Wrapped query strings** — continuation lines starting with `?` or `&` are
  appended to the URL, so a long query can stay readable in the file.
- **Form bodies** — when the content type is `application/x-www-form-urlencoded`,
  body lines starting with `&` are joined back into one encoded string.
- **File bodies** — `< ./payload.json` and `<@ ./payload.json` become
  `--data-binary '@./payload.json'`, so curl reads the file at run time.
- **`.ain` templates** — `[Method]`, `[Host]`, `[Query]`, `[Headers]` and `[Body]`
  sections, with `$VAR` and `${VAR}` substitution. Detected automatically, or
  forced with the format selector.

### Supplying variables

The variables box takes whichever shape you already have:

- a **flat JSON object**: `{"host":"https://api.example.com","token":"abc"}`
- a **JSON document of named environments**:
  `{"dev":{...},"prod":{...}}` — the same shape as an `http-client.env.json`
  file. Put the name you want (`dev`, `prod`, …) in the environment field.
- **`KEY=VALUE` lines**, like a `.env` file. A leading `export `, `#` comments
  and surrounding quotes are stripped.

**System variables** are resolved from your browser's clock: `{{$guid}}` /
`{{$uuid}}`, `{{$timestamp}}` and `{{$datetime}}` (both accept an offset such as
`-1 d` or `2 h`, and `$datetime` accepts `iso8601`, `rfc1123` or a strftime
pattern), `{{$randomInt 1 100}}`, and `{{$processEnv NAME}}` / `{{$dotenv NAME}}`
which read from the variables you supplied.

Anything still missing is, by your choice, left in place as a `{{placeholder}}`
you can fill in by hand, replaced with an empty string, or reported as an error
listing every name it couldn't find.

### Shaping the output

Pick the **shell** the command has to run in and the quoting follows: `bash`
(single quotes, `\` continuations), `cmd` (double quotes, `^`) or `powershell`
(single quotes with doubled escapes, backtick continuations, and `curl.exe` so
the command doesn't hit PowerShell's `Invoke-WebRequest` alias). Choose **short**
flags (`-X`, `-H`, `-d`) or **long** ones (`--request`, `--header`, `--data-raw`),
wrap the command across lines or keep it on one, and add `-L`, `--compressed` or
`-k` as needed.

### Privacy

Everything runs locally in WebAssembly. Nothing is sent: this tool never performs
the request, it only writes the command. Your hosts, bearer tokens and request
bodies never leave your device, and there is no sign-up.

## FAQ

<details>
<summary>Which request-file format does this expect?</summary>

The `.http`/`.rest` format used by the VS Code REST Client extension and the
IntelliJ / JetBrains HTTP Client — they are the same format, so a file written
for one works here. `.ain` template files are supported too, and are detected
automatically by their `[Section]` headers. If auto-detection guesses wrong on an
unusual file, force the format with the selector.

</details>

<details>
<summary>How do I use my http-client.env.json environments?</summary>

Paste the whole JSON document into the variables box and put the environment's
name — `dev`, `prod`, or whatever you called it — in the environment field. If
the document contains more than one environment and you don't name one, the tool
stops and lists the names it found rather than guessing.

Private values from an `http-client.private.env.json` overlay aren't merged
automatically, because only one document is accepted. Copy the private values
into the pasted JSON (or into the `KEY=VALUE` box) yourself.

</details>

<details>
<summary>Can it read my real environment variables or a .env file on disk?</summary>

No, and that's deliberate: the tool runs sandboxed in your browser, with no
access to your machine. `{{$processEnv NAME}}` and `{{$dotenv NAME}}` still work
— they resolve against the variables you paste in, so you can keep the file
unchanged and supply the values here.

</details>

<details>
<summary>What happens to a variable I don't have a value for?</summary>

That's the "missing variables" setting. **Keep** (the default) leaves the
`{{placeholder}}` untouched in the generated command, which is handy when you
want to hand someone a template to fill in. **Empty** substitutes an empty
string. **Error** refuses to generate anything and lists every unresolved name,
which is what you want when a silently blank token would send a request you can't
explain.

</details>

<details>
<summary>Does it send the request or show me a response?</summary>

No. This tool only rewrites the file as command text — it never opens a
connection. Copy the command and run it yourself when you're ready.

</details>

<details>
<summary>Why is my body shown as --data-binary '@file' instead of its contents?</summary>

Because the body was a `< ./payload.json` file reference, and the file lives on
your disk, not in the pasted text. `--data-binary '@./payload.json'` tells curl
to read exactly that file when the command runs, which is the faithful
translation — run the command from the same directory as the request file and it
behaves identically.

</details>

<details>
<summary>Which shell should I pick?</summary>

Whichever one will run the command. Quoting rules differ enough that a bash
command pasted into `cmd.exe` frequently breaks on the first quote. Pick
**powershell** on Windows PowerShell or pwsh — it also emits `curl.exe` rather
than `curl`, because `curl` is an alias for `Invoke-WebRequest` there and doesn't
accept curl's flags.

</details>

## Related tools

- [Article to EPUB](https://gizza.ai/tools/article-to-epub/): Turn article text or cleaned HTML into a valid EPUB 3 ebook with metadata, chapter splits, and a real table of contents. Runs in your browser.
- [Preview a Bulk File Rename](https://gizza.ai/tools/bulk-file-renamer/): Preview old-to-new filename mappings with find/replace, regex, numbering, case conversion, prefix/suffix, and collision warnings.
- [Citation Generator](https://gizza.ai/tools/citation-generator/): Free APA 7, MLA 9, Chicago and Harvard citation generator — format author, title, year, journal and URL into a correct reference right in your browser.
- [Config Merge Tool](https://gizza.ai/tools/config-merge/): Merge layered JSON, YAML, TOML and .env configuration files with override precedence, array strategy, null deletion and variable substitution.
- [Disk Usage by File Type](https://gizza.ai/tools/disk-usage-by-filetype/): Paste du, find or ls output and get a sorted bar chart of disk usage by file extension or category, with size, share and file count — free and private in your browser.
