Skip to main content

http2postman

Convert JetBrains HTTP Client / VSCode REST Client .http / .rest files into a Postman Collection v2.1 JSON file that imports cleanly into Postman.

Python 3.10+, standard library only.

Installation

pip install http2postman

Or install from this repository (editable install for development):

pip install -e .

On systems with an externally managed Python (Debian/Ubuntu: PEP 668), install in a virtual environment instead:

python3 -m venv .venv
source .venv/bin/activate
pip install -e .

Note: activate is a shell script meant to be sourced — the command is source .venv/bin/activate, not .venv/bin/activate. The name of the venv directory is your choice (.venv, .env, venv, ...) — just keep it consistent when activating.

No runtime dependencies are required — setuptools is only a build-time dependency.

If you do not want to install anything, the tool also runs directly from the repo checkout:

python3 -m http2postman requests.http

Usage

http2postman requests.http
http2postman requests.http -o my-collection.json
http2postman apis/ --name "My API"        # recursively scans directories
http2postman a.http b.http --quiet
http2postman requests.http --prefer-env dev   # bake env values into collection variables
http2postman requests.http --env-file .env    # resolve {{$dotenv VAR}} from a specific file
python3 -m http2postman requests.http
  • -o OUTPUT — output JSON path (default postman_collection.json next to the input).
  • --name NAME — collection name (default: first input file's basename).
  • --env-file PATH — .env file for {{$dotenv VAR}} resolution (default: .env next to each input).
  • --prefer-env NAME — use the named environment from http-client.env.json (plus http-client.private.env.json, merged on top) next to the first input as default values for the collection variables. Environment values win over file-level @var definitions; scalar values are coerced to strings, complex values to compact JSON. Missing file or environment name is an error (exit 1).
  • --quiet — suppress the stdout report.

Exit codes: 0 success, 1 conversion/validation failure, 2 usage error.

Output is written atomically (temp file + rename); source files are never modified.

--prefer-env example

JetBrains environment files map environment names to variable values:

// http-client.env.json (next to the .http file)
{
  "dev":  { "baseUrl": "https://dev.example.com",  "apiKey": "dev-key" },
  "prod": { "baseUrl": "https://prod.example.com" }
}
http2postman requests.http --prefer-env dev
# -> collection variables: baseUrl = https://dev.example.com, apiKey = dev-key

Secrets can live in http-client.private.env.json (same shape, merged on top). The report prints Env: dev so you can see which environment was used.

What is supported

  • ### request names, # @name overrides, all HTTP methods (unknown methods pass through verbatim)
  • headers (order/casing preserved; Content-Length dropped)
  • raw / JSON / XML / urlencoded / multipart / external-file bodies
  • GraphQL requests via X-REQUEST-TYPE: GraphQL
  • file-level @name = value variables -> collection variables
  • {{var}} tokens (kept byte-for-byte), JetBrains dynamic variables mapped to Postman equivalents ($uuid -> {{$guid}}, $random.email -> {{$randomEmail}}, etc. — unlisted $random.* tokens are reported)
  • ## Folder / @group folder grouping
  • JetBrains environments: --prefer-env NAME uses the values from http-client.env.json / http-client.private.env.json as the collection variable defaults (see the example above).
  • Scripts: < {% ... %} pre-request and > {% ... %} response scripts are captured and translated into Postman Pre-request Script / Tests tabs (client.test -> pm.test, client.assert -> pm.expect(!!(cond)[, msg]).to.be.true — JetBrains' assert is a truthiness check, and Postman's sandbox does not support Chai's .truthy, so the condition is boolean-coerced with !!() and asserted with the documented .to.be.true —, client.global.set -> pm.collectionVariables.set, request.variables.set -> pm.variables.set, request.environment.get -> pm.variables.get (resolves through the Postman variable chain, so --prefer-env defaults are visible to scripts), response.status -> pm.response.code, response.body -> pm.response.json() (parsed body, like JetBrains), response.contentType/time -> pm.response.*, ...). Unrecognized statements pass through unchanged.
  • dotenv: {{$dotenv VAR}} references resolve from the .env file next to each input file, or the file given with --env-file. Unresolved references are kept as-is and reported.
  • Auth: OAuth2 client-credentials token requests (POST to a token/oauth URL with grant_type=client_credentials and a literal Basic header) get a Postman oauth2 auth object; Bearer {{token}} and literal Basic base64(user:pass) / Basic {{user}} {{pass}} headers become bearer / basic auth objects (the header is removed).
  • WebSocket (WEBSOCKET ws://...) and gRPC (GRPC host/service/method) blocks are parsed and reported under Unsupported: — the Postman Collection v2.1 schema cannot express them — with a file:line reference for manual porting.

The stdout report lists Requests: N | Folders: N | Variables: N | Scripts: N (translated script blocks), an Env: line when --prefer-env is used, and an Unsupported: line for anything left (unmapped dynamic variables, unresolved dotenv refs, WebSocket/gRPC blocks).

Tests

python3 -m unittest discover -s tests

Metadata

Release files for http2postman 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for http2postman 0.1.0
File Size Uploaded Provenance
http2postman-0.1.0.tar.gz 40.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for http2postman 0.1.0
File Interpreter ABI Platform
http2postman-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 66.6 kB

Release files / http2postman-0.1.0.tar.gz

Download URL http2postman-0.1.0.tar.gz
Size 40.2 kB
Tags Source
SHA-256 checksum
How to use checksums
2fc7ff422c17658c65d7fdcbd0bb1e0a07c81464ece29787dda7a45117876141
BLAKE2b-256 checksum
How to use checksums
288f9a5d259329d46fe4ec03df2ca8f2179f394e4dd15d079374fba69737f2c9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.13

Release files / http2postman-0.1.0-py3-none-any.whl

Download URL http2postman-0.1.0-py3-none-any.whl
Size 26.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bb19cd86557e3b5ccfd28136196755582d33d52dedee225dc3b0668d48391a2b
BLAKE2b-256 checksum
How to use checksums
96fa60a02a0c34106e61e57e27777737169952167aae259fbc63c568784654e1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.13

Security for http2postman 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page