cURL to Postman Collection

Convert a cURL command into a Postman collection.

cURL Command
Postman Collection Output
Postman Collection code appears here

Related Tools

Documentation

What is curl-to-Postman?

This tool converts a curl command into a Postman Collection v2.1 JSON document — the exact schema Postman's own "Import" dialog reads — so you can paste a curl snippet from API docs or browser devtools straight into a shareable, runnable Postman request.

How it works

After parsing the curl flags into method, url, headers, body, form, and auth, the generator builds a collection object with one item containing a request. The URL is split into its parts using the browser's built-in URL parser — protocol, host (as an array of dot-separated labels), path segments, and query parameters — wrapped in a try/catch: if the curl command's URL isn't a full absolute URL (missing a scheme, for instance), parsing throws and the generator falls back to a bare raw string field instead of guessing at a split. A JSON-shaped -d body becomes { mode: 'raw', raw: <body>, options: { raw: { language: 'json' } } } (detected by a leading { or [), while -F form fields become a formdata body mode. -u user:pass becomes an auth: { type: 'basic' } block with the username/password already filled in.

Features

  • Outputs a complete Postman Collection v2.1 JSON file, ready for Postman's Import button
  • URL correctly split into protocol/host/path/query when it's a full absolute URL
  • JSON bodies auto-tagged with language: 'json' for Postman's syntax highlighting
  • -F file fields marked type: 'file' so Postman prompts for the actual file on send
  • -u Basic Auth pre-filled into the collection's auth block

Example

Input: curl -X POST https://api.example.com/v1/login -H "Content-Type: application/json" -u admin:s3cret -d '{"username":"admin","remember":true}'

Output:

{
  "info": {
    "name": "POST https://api.example.com/v1/login",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "item": [
    {
      "name": "POST https://api.example.com/v1/login",
      "request": {
        "method": "POST",
        "header": [
          { "key": "Content-Type", "value": "application/json" }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\"username\":\"admin\",\"remember\":true}",
          "options": { "raw": { "language": "json" } }
        },
        "auth": {
          "type": "basic",
          "basic": [
            { "key": "username", "value": "admin", "type": "string" },
            { "key": "password", "value": "s3cret", "type": "string" }
          ]
        },
        "url": {
          "raw": "https://api.example.com/v1/login",
          "protocol": "https",
          "host": ["api", "example", "com"],
          "path": ["v1", "login"]
        }
      },
      "response": []
    }
  ]
}

Common errors

If the curl command's URL has no scheme (e.g. it starts with just a hostname or an environment-variable placeholder), the URL parser can't split it and the collection's url field falls back to a bare raw string with no host/path/query breakdown — Postman still imports it, but variable substitution UI (host/path highlighting) won't kick in until you fix the URL. Query string parameters passed via -G are folded into the URL before parsing, so they still show up correctly in the query array.

Best practices

Save the output as a .json file and use Postman's File → Import rather than pasting into the request builder by hand, so the collection metadata (name, schema version) is preserved. For requests with credentials, consider replacing the hardcoded auth values with a Postman environment variable after import, rather than committing secrets into a shared collection.

Frequently Asked Questions

Can I import the output directly into Postman?

Yes — the output is a complete Postman Collection v2.1 JSON file (the same format Postman's own "Import" button reads), including the info.schema URL Postman uses to recognize the format.

How is the URL split into host/path/query?

Using the browser's built-in URL parser, so it correctly separates the protocol, host, path segments, and query parameters as long as the curl command has a full absolute URL (with http:// or https://). A bare hostname or relative path without a scheme falls back to a raw URL string only, since it can't be reliably split without one.

Does it support file uploads (-F with @file)?

Yes — form fields become Postman's formdata body mode, with file fields (values starting with @) marked as type: "file" so Postman prompts you to pick the actual file when you run the request.

What happens to -u (Basic Auth)?

Converted to Postman's auth: { type: "basic" } block with username and password filled in, so the request is pre-authenticated the moment you import it rather than needing to be reconfigured by hand.