Skip to content

cURL and HAR to OpenAPI converter

Runs in your browser. Nothing is uploaded.

Paste cURL commands (one or more, each starting with curl) or upload a HAR file from your browser's network tab, and get an OpenAPI document you can edit and publish.

In the spec, credential headers and cookies, values under names such as password, token or api_key, and values that look like tokens become <redacted>; check the examples before you publish.

Input

curl 'https://api.example.com/v1/orders?status=open&limit=20' \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN'

curl -X POST https://api.example.com/v1/orders \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"item": "book", "quantity": 2, "gift": false}'

curl https://api.example.com/v1/orders/1042 -H 'Accept: application/json'

Result

Paste, upload or load a file to start

How it works

Paste cURL commands or upload a HAR file. The cURL commands are read as text and turned into a HAR first; the HAR then goes through the converter of APIGit's HAR import, which groups the requests by path and method and writes their parameters, request bodies, schemas and examples. Secret-looking values are redacted on the way.

The sample has three commands: a list with a query string, a POST with a JSON body, and a read by id. Two of them carry Authorization: Bearer YOUR_TOKEN. The start of the generated document:

openapi: 3.0.3
info:
  title: API from recorded requests
  version: 1.0.0
  description: Generated by APIGit's cURL and HAR to OpenAPI converter. The examples come from the recorded requests and responses; values under secret-looking names (password, token, api_key, …) and values that look like tokens were replaced with <redacted>, and a token in a path became a {token} parameter. Review the paths, parameters, schemas and examples before you publish it.
servers:
  - url: https://api.example.com

The query string became two parameters with their examples:

    get:
      operationId: get-v1-orders
      parameters:
        - description: status
          in: query
          name: status
          schema:
            type: string
            example: open
        - description: limit
          in: query
          name: limit
          schema:
            type: integer
            example: 20
      responses:
        "200":
          description: Success
      summary: List orders
      tags:
        - Default

The JSON body of the POST became a request body with a schema and an example (part of POST /v1/orders):

      parameters: []
      requestBody:
        content:
          application/json:
            examples:
              example-0001:
                value:
                  gift: false
                  item: book
                  quantity: 2
            schema:
              additionalProperties: false
              properties:
                gift:
                  type: boolean
                item:
                  type: string
                quantity:
                  type: integer
              title: V1OrdersPostRequest

The token is in neither: the Authorization header was not carried into the spec.

What it does not do

  • It cannot catch every secret. It redacts by name and by shape; a credential with an ordinary name and an ordinary look stays. Read the generated spec before you share or publish it.
  • It does not turn ids in paths into parameters, except a value that looks like a token.
  • It does not add a security scheme, descriptions or error responses: it describes what the requests show.
  • It does not run the commands or call the API, so cURL input gives no responses; a HAR file does.
  • Nothing is uploaded, and nothing is kept outside this browser.

This tool and APIGit

This toolWith APIGit
Convert pasted commands or a HAR fileImport a HAR file into a repository and keep only the requests of the servers you select
One generated documentPaths from a HAR file or another spec imported into the spec you are editing
A draft to reviewThe draft committed to Git, reviewed in a pull request and checked with the Governance view
No mockA mock server from the spec, answering with its examples

Questions and answers

What can I paste?
One or more cURL commands (as a browser's Copy as cURL or an API's docs give them), or a HAR file a browser's developer tools saved. A HAR file also gives the converter the responses, so the operations get response examples and schemas.
What happens to tokens and passwords?
Values under secret-looking names (password, token, api_key and the like) and values shaped like a credential (a JWT, a Bearer or Basic value, a long random token) are replaced with <redacted>, and a token in a path becomes a {token} parameter. It cannot catch every secret: read the generated spec before you share it.
Is anything uploaded or executed?
No. The commands are read, never run: a command with a shell expansion such as $(...) is skipped, not evaluated. The conversion happens in your browser.
Why is /orders/1042 not /orders/{id}?
The converter keeps the paths it sees. Replace an id in a path with a parameter yourself; requests to /orders/1042 and /orders/1043 become two paths until you do.
Why is there no security scheme in the result?
Credentials are kept out of the spec, so the Authorization header does not become a scheme. Add the scheme your API uses under components.securitySchemes.
Which lines were not converted?
A line that is not part of a cURL command, or a command the converter cannot read, is listed with the reason below the result. If nothing converts, the page says why.