cURL Parser

Parse cURL commands into structured components. Extract URL, method, headers, body, auth, and generate JavaScript fetch() and axios equivalents.

Parse Components Generate fetch() Generate axios

How to Use cURL Parser

1

Paste cURL Command

Copy a cURL command from browser DevTools (right-click a request and "Copy as cURL") and paste it into the input area.

2

Parse Components

The command is broken down into URL, method, headers, body, auth, and cookies automatically.

3

Get Code

Copy the generated fetch() or axios code for use in your JavaScript projects.

What is cURL?

cURL (Client URL) is a command-line tool and library for transferring data using various protocols. It is widely used for testing APIs, debugging HTTP requests, and automating data transfers. Browser developer tools can export network requests as cURL commands, making it easy to share and reproduce HTTP requests.

Command-Line Tool

cURL is a command-line tool for transferring data using various protocols including HTTP, HTTPS, FTP, and more.

Browser DevTools Export

Most browser DevTools let you right-click a network request and "Copy as cURL" to get the exact command.

Code Conversion

Convert cURL commands to JavaScript fetch() or axios code for easy integration into your web applications.

Frequently Asked Questions

Can it generate fetch() code from cURL?

Yes. The tool converts cURL commands to JavaScript fetch() and axios code snippets. The generated code preserves the URL, method, headers, and body from the original cURL command.

Does it handle POST data and file uploads?

Yes. It parses -d/--data, --data-raw, and --data-binary flags including JSON payloads. JSON body data is automatically formatted with proper indentation in the generated code.

What cURL flags are supported?

Common flags including -X (method), -H (headers), -d (data), -b (cookies), -u (auth), -k (insecure), -L (follow redirects), --compressed, and more. Complex or unusual flags may not be fully parsed.

How do I convert a cURL command into PHP code?

The tool maps flags to PHP's curl API: the URL goes into CURLOPT_URL, each -H into CURLOPT_HTTPHEADER, -d into CURLOPT_POSTFIELDS, and -u into CURLOPT_USERPWD. Paste the command, copy the generated snippet, and the boilerplate (RETURNTRANSFER, error handling) is generated for you.

What does the -H flag do and how are repeated headers handled?

-H 'Content-Type: application/json' adds one header; repeat -H for each additional header and they all send. -H can also remove a header by naming it with no value (-H 'User-Agent:') or send an empty value with a trailing semicolon. Multiple -H flags preserve order, which matters for a few APIs.

How is authentication passed in cURL?

HTTP Basic is -u user:password (curl base64-encodes it into an Authorization header). Bearer tokens go as a header: -H 'Authorization: Bearer <token>'. API keys appear either as headers or as query parameters depending on the service. Warning: secrets on the command line land in shell history - prefer a netrc file or environment variable.

What is the difference between -d, --data-binary, and -F?

-d sends data as application/x-www-form-urlencoded and strips newlines; --data-binary sends the payload verbatim, which JSON APIs need; -F builds a multipart/form-data request, the only option for file uploads. GET-style parameters use -G combined with -d, which moves the data into the URL query string.

Why does converted code fail when the cURL command worked?

Usually quoting: the shell strips quotes before curl sees them, but the target language re-interprets them - single quotes that are safe in the shell need different handling in JavaScript. Other traps: line-ending backslashes from multiline commands, percent signs in URLs breaking %-formatting in some languages, and cookie files referenced by -b/-c that don't exist in the new environment.

{-- * External Resources Component(#18 Phase 3b 内容佐证工程) * 工具页「权威引用」区块:RFC / W3C / WHATWG / ECMA / IANA / 官方规范站 / Wikipedia。 * * - 接受 :slug 属性 → 经 config/tool-sources.php 家族矩阵渲染该工具的权威引用 * - slug 未命中映射时不渲染(无权威来源的工具静默跳过) * - 链接 title 保持英文(引用源专名);description 经 * common.resources.descriptions.{key} 本地化,lang 未命中回退英文(线上不裸奔) * - 链接保持 dofollow(rel="noopener noreferrer") * * @param string|null $slug --}}