Convert curl to JSON
Convert curl commands to a structured JSON representation. curl2code runs entirely in your browser via WebAssembly — your data stays private. For HAR format, try our curl to HAR converter. For raw HTTP, see curl to HTTP. Below are ready-to-use JSON output examples.
How to copy curl from your browser
- 1
Open DevTools
Press F12 or Ctrl+Shift+I to open your browser developer tools.
- 2
Go to the Network tab
Click the Network tab and perform the action that triggers the HTTP request.
- 3
Copy as cURL
Right-click the request → Copy → Copy as cURL. Then paste it above.
Frequently Asked Questions
What is the JSON output format?
curl2code's JSON output converts a curl command into a structured JSON representation of the HTTP request. It includes url, method, headers, body, and query fields in a clean, parseable format. This is useful for importing into tools, generating documentation, or processing requests programmatically.
JSON vs HAR vs raw HTTP — which format to use?
JSON is ideal for programmatic use — easy to parse and transform in any language. HAR follows the W3C standard for browser tooling. Raw HTTP shows the actual protocol text. Choose JSON for building tools, HAR for browser analysis, HTTP for learning. See also curl to HAR and curl to HTTP.
How is authentication represented in JSON output?
Auth headers appear in the headers object: {"Authorization": "Bearer token123"}. Basic auth credentials may appear both as a header and in a separate auth field depending on the curl flags used. curl2code preserves all authentication information in the structured JSON output.
How is form data represented in JSON output?
Form data appears in the body field as a structured object. For JSON bodies, the content is nested directly. For form-urlencoded, fields appear as key-value pairs. For multipart, each part is listed with its name, value, and content type. The headers object includes the Content-Type.
How to validate the JSON output?
The JSON output is always valid JSON — parse with JSON.parse() in JavaScript, json.loads() in Python, or any JSON library. Validate the structure has the expected fields: url (string), method (string), headers (object). Use JSON Schema for strict validation in automated pipelines.
How to use the JSON output programmatically?
Parse the JSON and use it to build HTTP requests in any language. Example in JavaScript: const req = JSON.parse(output); fetch(req.url, { method: req.method, headers: req.headers, body: req.body }). This enables curl-to-code conversion in custom toolchains. See curl to JavaScript for direct code generation.
How to use JSON output for debugging?
Pipe the JSON output through jq for pretty-printing and querying: jq '.headers' to inspect headers, jq '.body | fromjson' to parse JSON bodies. Compare JSON outputs of different curl commands to spot differences. JSON format makes it easy to diff and version-control HTTP requests.
What tools can consume the JSON output?
Import into Postman, Insomnia, or Hoppscotch for visual API testing. Use jq for CLI processing. Feed into CI/CD pipelines for automated API testing. Convert to code in any language using the structured data. For TypeScript type definitions, see curl to TypeScript.
How to represent a POST request with JSON body in JSON?
Use curl's -X POST -d "{"key":"value"}" -H "Content-Type: application/json" and curl2code will convert it to JSON format: { "method": "POST", "body": {"key": "value"}, "headers": {"Content-Type": "application/json"} }. The JSON body and Content-Type header are preserved in the output. curl2code handles both inline JSON and @file.json references.
How to include Bearer token authorization in JSON?
When you convert curl -H "Authorization: Bearer YOUR_TOKEN" URL with curl2code, the Bearer token is preserved in the JSON output: { "headers": { "Authorization": "Bearer YOUR_TOKEN" } }. Both -H "Authorization: Bearer ..." and OAuth token flags are detected automatically.
How is Content-Type represented in JSON format?
When converting curl -H "Content-Type: application/json" URL, curl2code outputs the Content-Type in JSON as: { "headers": { "Content-Type": "application/json" } }. Common types include application/json, application/x-www-form-urlencoded, and multipart/form-data. curl2code preserves the exact Content-Type from the original curl command.