What is the cURL Converter?
ToolMint's cURL Converter translates one pasted cURL command into a JSON request description, JavaScript Fetch or Python Requests code. It parses the command as inert text in your browser, creates a normalized request model, and generates code without executing the request or contacting its destination.
This is useful when API documentation gives you a cURL example but your application needs fetch() or Python's requests library. The converter preserves supported request methods, URLs, headers, literal bodies, query data and authentication details, then calls out behavior that cannot be reproduced exactly.
Can I convert cURL to JSON?
Yes. Choose Request JSON, then Convert, to inspect a JSON description of the request. Copy it or select Download JSON to save curl-request.json. Conversion runs locally and does not contact the URL.
| What you need | What to do |
|---|---|
| Describe a cURL request as JSON | Choose Request JSON. Review the method, URL, ordered headers and query entries, body, authentication and request options. |
| Inspect JSON already supplied as a request body | In the JSON POST example below, the JSON is the text inside -d's shell quotes. Copy that JSON text into JSON Formatter to inspect it separately. Do not paste the whole cURL command into a JSON editor. |
| Turn a request into application code | Choose JavaScript Fetch or Python Requests and review the generated body and headers. |
| Obtain a server's JSON response | This requires running a request in your own environment. ToolMint does not contact the endpoint and cannot show its response. |
A JSON request body is data sent to a server; a JSON response is data received from it. Converting the command does not turn one into the other. The curl manual documents --data request-body behavior. Review the large-ID example before rebuilding JSON containing numeric identifiers, and remove real credentials before sharing either the command or generated code.
What the JSON request description contains
ToolMint's JSON uses its own documented field names for inspection and scripting. It is not a server response or a ready-to-import Postman collection. A receiving application needs to map these fields to its own request format.
| Field | Meaning |
|---|---|
method, url |
Parsed method and URL, including query data appended by -G. The URL retains its original encoding. |
headers |
Ordered {name, value, inferred} entries. Repeated names remain separate; inferred identifies a header supplied by the parser rather than an explicit -H. |
query |
Ordered, decoded {name, value} entries. Repeated names and empty values remain separate; + decodes as a space. Refer to url for original encoding or a distinction such as flag versus flag=. |
body |
null for no body; {type, raw} for text data; or {type, fields} for ordered scalar multipart fields. |
auth, cookies, userAgent, referer |
Parsed values from the corresponding options, or null when absent. Basic authentication is described separately from explicit Authorization headers. |
followRedirects, verifyTls, compressed |
Descriptions of the parsed request options. They do not execute or configure a network client. |
unsupportedOptions |
Unsupported option names. Their values and behavior are not represented; read the conversion notes. |
For example, convert this fictional request:
curl 'https://api.example.com/items?tag=one&tag=two' -H 'X-Trace: first' -H 'X-Trace: second'
The JSON contains both X-Trace header entries and both tag query entries in order. They are lists rather than objects keyed by name, so later values do not overwrite earlier ones. URL decoding is for the query list; use the url string when exact encoded spelling matters. See the URL Standard for query parsing behavior.
Why JSON body text stays a string
Request JSON always stores a text body in body.raw. It does not parse and rebuild that text, even when its content type is JSON. After reading the downloaded outer JSON, body.raw contains the body text produced by the cURL parser. Shell quotes and continuations have already been processed; this is not a copy of the entire original shell command.
This preserves number spelling such as 9007199254740993, 1.2300 or 1e3, whitespace and duplicate JSON member names in the parsed body. An invalid JSON body also remains text; exporting a request description does not validate or repair its body. Escaped quotes in the outer JSON are expected. Use JSON Formatter when you separately want to inspect the body.
Convert a JSON POST with a bearer header
Select Load JSON POST, choose JavaScript Fetch, then Convert. The example is fictional; the tool never contacts its URL.
curl -X POST https://api.example.com/users \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer YOUR_TOKEN' \
-d '{"name":"Jane","active":true,"note":null}'
The output keeps POST, both headers and the three JSON values. Fetch uses JSON.stringify(...). Switch to Python Requests to see json=payload, with True and None in the Python object. These are request-body values; they are not response parsing instructions. The YOUR_TOKEN placeholder is copied into generated code, so replace it only when running the code in your own environment.
Preserve a large integer ID in the JSON body
Select Load large-ID example and Convert, or paste:
curl -X POST https://api.example.com/events \
-H 'Content-Type: application/json' \
--data-raw '{"event_id":9007199254740993,"active":true}'
9007199254740993 exceeds JavaScript's maximum safe integer, 9007199254740991. Converting it to a JavaScript Number can round it to 9007199254740992. ToolMint detects this unquoted integer and keeps the entire original body as a string instead of rebuilding an object.
| Output target | Expected body output |
|---|---|
| JavaScript Fetch | A raw string containing 9007199254740993, without JSON.stringify(...) |
| Python Requests | data=... containing the same raw JSON text, rather than json=payload |
| Request JSON | body.raw contains the original parsed body string, including the large integer |
Keep the Content-Type: application/json header. Python's integers can represent this value; the raw output here avoids losing it during the converter's JavaScript parsing step. Check the generated body and compatibility warning before copying it. This safeguard covers unquoted integer literals outside the safe range; it is not a promise of arbitrary decimal precision or byte-identical serialization for all JSON. If you control the API, string IDs may be appropriate, but changing a number to a string changes the payload type and must match the API contract.
How to convert cURL to Fetch
- Paste a single cURL command into the input area.
- Choose JavaScript Fetch.
- Select Convert.
- Review the method, host, header count, body type and compatibility notes.
- Copy the JavaScript or download
curl-to-fetch.js.
The generated code omits unnecessary options for a simple GET. POST, PUT, PATCH, DELETE, HEAD and safe custom methods include the method explicitly. JSON bodies use JSON.stringify() only when parsing and re-serialization will not change value semantics.
How to convert cURL to Python Requests
Choose Python Requests before converting. The generator imports requests, assigns the URL, and uses requests.get(), requests.post() or another convenience method when appropriate. A valid custom method uses requests.request().
Only required arguments are emitted. Depending on the command, these can include headers, json, data, files, auth, cookies, allow_redirects and verify. The converter creates code; it does not run Python or install Requests for you.
Supported cURL options
The first version focuses on common HTTP request options:
-Xand--requestfor standard or syntactically valid custom methods-Hand--header, including repeated headers-d,--data,--data-raw,--data-binaryand--data-urlencodefor literal data-Fand--formfor scalar text fields-uand--userfor basic authentication-band--cookiefor simple cookie strings--url,--user-agentand--referer-L,--head,-G,--insecureand--compressed
The tokenizer understands single and double quotes, common escaped characters, Bash backslash line continuations, and a narrow CMD caret continuation. It accepts one HTTP or HTTPS transfer at a time.
What cannot be converted exactly
The converter rejects shell substitutions, variables, pipelines, redirections, command chaining and globbing instead of interpreting them. It also does not convert local file or stdin references, uploads, client certificates, proxy settings, forced HTTP versions, --resolve, --connect-to, DNS overrides or non-HTTP protocols.
These limits are intentional. A browser cannot safely read an arbitrary local path from pasted text, and generated code should not pretend that browser security controls match a command-line client.
Headers and authentication
Repeated cURL headers remain separate in the normalized request model. JavaScript uses the Headers interface when duplicates need to be represented, while Python includes a warning because a normal Requests header mapping cannot preserve duplicate names faithfully.
Authorization headers are preserved. Basic authentication supplied with -u becomes a Basic header in Fetch and an auth tuple in Python. Bearer tokens, API-key headers, cookies, signed URLs and user credentials can be sensitive, so the tool displays a local warning when it detects likely credentials. It does not redact values automatically because doing so would change the generated request.
Before sharing a snippet, replace real secrets with placeholders. For additional transport checks, inspect a public endpoint with ToolMint's HTTP Header Checker, but never submit a private or signed URL to a server-side checker.
JSON and form data
When the content type is JSON and the body parses without unsafe numeric changes, Fetch receives JSON.stringify(...) and Python receives json=.... A body containing an unquoted integer outside JavaScript's safe integer range stays a raw string so conversion does not silently change it. The JSON Formatter can help inspect ordinary JSON, and the guide to pretty-printing JSON explains common validity problems.
Form URL-encoded data preserves repeated keys without decoding and re-encoding already escaped values unnecessarily. With -G, applicable data is appended to the existing query string instead of becoming a request body. Review the URL encoding and Base64 guide or use the URL Encoder / Decoder when you need to inspect percent-encoded values. The Base64 Encoder / Decoder handles a different representation and is not a substitute for URL encoding.
Multipart conversion supports scalar text fields. File-backed fields such as -F "file=@photo.jpg" are rejected because a pasted filesystem path cannot be carried into portable browser code.
Privacy and credentials
Parsing and generation happen synchronously in the current browser tab. ToolMint does not execute the command, fetch its URL, resolve its hostname, send the input to an API, save it to localStorage or include private request data in analytics. Input disappears when you clear it, refresh the page or close the tab.
Generated output, including Request JSON, can still contain the credentials that were present in the pasted command. Treat that output like the original command: review it before downloading, committing or sending it to another person.
cURL vs Fetch differences
cURL does not follow redirects by default, while Fetch normally does. When -L is absent, the generator uses redirect: "manual" and warns that browser manual-redirect responses can be opaque. When -L is present, the normal Fetch redirect behavior is used.
Browser Fetch does not expose a cURL-style switch for bypassing TLS certificate validation. It can also restrict or override headers such as Cookie, User-Agent and Referer. The converter reports these differences rather than generating fake compatibility code. The HTTP security headers guide provides context for browser and server header controls.
cURL vs Python Requests differences
Python Requests runs outside the browser and can represent more command-line behavior, including verify=False for the cURL --insecure option. That setting weakens certificate verification, so generated code includes a visible warning and should not be copied into production without a deliberate security review.
Redirect defaults also depend on the Requests method. The generator sets allow_redirects when needed to reflect the cURL choice, but proxies, certificates, low-level connection routing and HTTP-version forcing remain outside this converter's scope.
Explore more browser-side utilities in the Developer tools category.