User Rating 0.0 โ˜…โ˜…โ˜…โ˜…โ˜…
Total Usage 0 times
Category JSON Tools
cURL Command
Examples:
JSON Output
Your JSON output will appear here...
Is this tool helpful?

Your feedback helps us improve.

โ˜… โ˜… โ˜… โ˜… โ˜…

About

cURL commands encode HTTP request semantics in a dense, flag-heavy shell syntax. A misread -H flag or a dropped --data-raw payload during manual translation into application code causes silent API failures - wrong Content-Type, missing auth headers, truncated bodies. This converter parses the full cURL argument grammar including shell quoting rules, backslash line continuations, and flag aliases, then emits a clean JSON object you can directly feed into fetch(), Axios, or any HTTP client config. It handles implicit method detection: if --data is present but no -X flag, the method resolves to POST per cURL specification. Limitations: this tool does not resolve environment variables ($VAR) or execute sub-shells ($(cmd)). Glob patterns and --config file references are ignored.

curl json converter api http request parser developer-tools rest

Formulas

The parser operates as a two-stage pipeline. Stage 1 is shell tokenization. Stage 2 is flag-to-field mapping.

tokenize(input) โ†’ [token0, token1, โ€ฆ, tokenn]

Tokenization splits the raw cURL string respecting shell quoting rules. Single-quoted strings ("...") preserve all characters literally. Double-quoted strings ("...") allow backslash escapes (\", \\, \n). Backslash-newline sequences (\ followed by newline) are treated as line continuations and removed.

parse([token0..n]) โ†’ { url, method, headers, body, auth, cookies, options }

Method resolution follows cURL precedence: explicit -X wins. If absent and -I/--head is set, method = HEAD. If -d/--data/-F is present and no -G, method = POST. Otherwise method = GET. When -G is set, any -d data is appended to the URL as query parameters instead of being sent as body.

Where url = the target endpoint, method = HTTP verb, headers = key-value map of request headers, body = request payload (string or structured object), auth = authentication credentials object, cookies = parsed cookie key-value pairs, options = behavioral flags (redirects, timeouts, TLS settings).

Reference Data

cURL FlagAliasJSON FieldDescription
-X--requestmethodHTTP method (GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS)
-H--headerheadersRequest header in Key: Value format
-d--databodyRequest body (URL-encoded by default)
--data-raw - bodyRequest body sent without special interpretation
--data-binary - bodyBinary data body (preserves newlines)
--data-urlencode - bodyURL-encodes the data value
-F--formbody / multipartMultipart form data field
-u--userauthBasic auth credentials user:password
-A--user-agentheaders["User-Agent"]Sets User-Agent header
-e--refererheaders["Referer"]Sets Referer header
-b--cookiecookiesSend cookies (name=value; name2=value2)
--compressed - options.compressedRequests compressed response (adds Accept-Encoding)
-k--insecureoptions.insecureSkip TLS certificate verification
-L--locationoptions.followRedirectsFollow HTTP redirects
--connect-timeout - options.connectTimeoutConnection timeout in seconds
--max-time-moptions.maxTimeMaximum total request time in seconds
-I--headmethod โ†’ HEADFetch headers only (sets method to HEAD)
-G--getmethod โ†’ GETForces GET even if -d is present (appends data as query string)
--url - urlExplicit URL (alternative to positional argument)
-o--outputoptions.outputWrite output to file (informational only)
-s--silentoptions.silentSilent mode (suppress progress meter)
-v--verboseoptions.verboseVerbose output mode

Frequently Asked Questions

The tokenizer pre-processes the input by replacing all occurrences of a backslash immediately followed by a newline character (\) with nothing. This joins continuation lines into a single logical line before tokenization begins, matching standard POSIX shell behavior.
The explicit -X flag always takes priority over implicit method detection. If you set -X GET with -d data, the output JSON will show method as GET and still include the body field. This mirrors actual cURL behavior, though many servers will ignore the body in a GET request. The converter will emit a warning note about this uncommon combination.
Yes. For --data-urlencode, the parser applies URL encoding to the value portion. If the argument is in name=value format, only the value is encoded. If it is =value, the entire value is encoded. If it contains no equals sign, the entire string is treated as a value to encode. This matches cURL specification section on URL encoding behavior.
Per HTTP specification (RFC 7230 ยง3.2.2), multiple headers with the same field name are valid and should be combined. This converter preserves the last value for each header key, which matches how most HTTP clients behave in practice. If you need to send duplicate header keys, note this in your implementation code manually.
Yes. Browser DevTools (Chrome, Firefox, Edge) export cURL commands using the "Copy as cURL" feature. These commands use standard cURL syntax with double-quoted headers and --compressed flags. The parser handles all these patterns including the Windows cmd.exe variant (which uses double quotes and ^ for line continuation instead of backslash).
Environment variable expansion ($VAR, ${VAR}), sub-shell execution ($(command)), glob patterns ({a,b,c}), --config file references, --cert/--key TLS client certificate paths, and SOCKS proxy settings (--socks5). These features require runtime context or filesystem access that a browser-based parser cannot provide. The tool will parse the flags but note them as unresolvable in the output.