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 tool | With APIGit |
|---|---|
| Convert pasted commands or a HAR file | Import a HAR file into a repository and keep only the requests of the servers you select |
| One generated document | Paths from a HAR file or another spec imported into the spec you are editing |
| A draft to review | The draft committed to Git, reviewed in a pull request and checked with the Governance view |
| No mock | A mock server from the spec, answering with its examples |