Code snippets
The snippet panel turns the request you are editing into code in one of eight languages. It is generated locally from the request itself. Nothing is sent.
Open the panel
- Press
Cmd/Ctrl+Kto open the palette. - Type
Toggle code snippet paneland run it. This toggles the right panel. The command has no keyboard shortcut.
With no request open, the panel says Open a request to see its generated code.
The panel follows the active tab's current draft, including edits you have not saved yet. The result is syntax-coloured and read-only. Use the copy button to put it on the clipboard.
Languages
The language menu lists these labels. The id is what the language argument of the snippet_generate tool takes.
| Id | Label in the panel |
|---|---|
curl (default) | cURL |
raw-http | Raw HTTP/1.1 |
fetch | JavaScript (fetch) |
python | Python (requests) |
go | Go (net/http) |
rust | Rust (reqwest) |
powershell | PowerShell |
node-axios | NodeJS (axios) |
Options
The gear button in the panel opens two options:
| Option | Values | Default |
|---|---|---|
| Indent | 2 spaces, 4 spaces, Tab | 2 spaces |
| Include boilerplate | on / off (wraps the request in imports and a main) | on |
The tool takes indent (an integer from 0 to 8; 0 means a tab) and include_boilerplate. The cURL output uses a fixed style and ignores both options.
What goes into a snippet
- Variables stay unresolved. A URL built from a base-URL variable keeps its variable reference as written. The snippet is a template you can reuse. The panel's tooltip says the resolved URL is shown in the Console. Values are never substituted, so secret variable values do not enter snippets. Text you type literally into a request does.
- Unsupported body kinds become a comment. If a language cannot express a body kind, the snippet shows a comment instead of dropping the request. For example, Go renders form-data rows as comments and suggests a
multipart.Writer.
Limits
Snippets are for HTTP requests only. gRPC and WebSocket requests have no snippet. snippet_generate answers snippet_generate supports HTTP requests only; gRPC/WS snippets are not implemented yet.
grpcurl snippet is planned (d.grpcurl-snippet in the parity file) but does not exist yet.Headless
snippet_generate is read-only.
- It takes
collection,request, and optionallylanguage,indentandinclude_boilerplate. - It returns
{"language": …, "snippet": …}. - It reads the saved request, not an unsaved draft.
See Automation tools.