Format
Validate
Convert
Query
Generate

cURL to code converter

Turn a cURL command into Python, JavaScript, PHP, Go, Java, C#, Rust or Ruby code.
Output
216 B · paste or drop a file
1 2 3 4
✓ complete216 B → 321 B0.0 ms

About cURL to Code

This cURL to code converter turns a cURL command into request code. Copy a command from your browser's DevTools, an API doc or a terminal, and get the same request as Python requests, JavaScript fetch, Node.js axios, PHP cURL, Go net/http, Java HttpClient, C# HttpClient, Rust reqwest or Ruby Net::HTTP.

Pick JSON output to inspect the command instead: the method, URL, headers, body, auth and any flags the converter did not translate. The command is only read as text. It never runs, and no request is sent.

Runs in your browser. Nothing is uploaded.

How it works

Text-only tokenizing

Single quotes, double quotes, escapes and backslash line continuations are read only to split the arguments. Variables, substitutions, globs, redirects and shell operators are never evaluated.

What gets converted

The method (-X), URL, headers (-H), body (-d, --data-raw, --data-binary, --json), basic auth (-u), cookies (-b), -G query data and -I HEAD requests carry over to the code. Flags with no equivalent, such as -k or -o, are listed in a comment at the top.

JSON bodies stay readable

When the body is valid JSON, fetch code builds it with JSON.stringify, axios passes an object as data, and Python code passes a dict through json=, with true, false and null written as True, False and None. The other languages send the body as a string literal, exactly as curl would.

Idiomatic code per language

Each target uses the standard or most common HTTP client: fetch, axios, requests, PHP's cURL extension, Go net/http, java.net.http (Java 11+), .NET HttpClient, reqwest's blocking client and Ruby Net::HTTP. Basic auth uses each client's own auth option where it has one, and headers a client sets itself, such as Host in Java, are noted in a comment.

Credentials hidden by default

Authorization headers, cookies, API key headers and basic auth passwords are replaced with [REDACTED] in every output. Turn redaction off when you need the real values in the code.

Frequently asked questions

Will this run the cURL command?

No. The command is parsed as plain text. No process, shell, file read or HTTP request is created.

How do I convert cURL to Python requests?

Paste the command and pick Python. You get a script that imports requests, sets the URL, headers and body, calls requests.post or the matching method, and prints the status and response text.

How do I convert cURL to JavaScript fetch?

Paste the command and keep the fetch output. The code uses the standard fetch API with await, so it runs in browsers, Node.js 18 and later, Deno and Bun.

How do I convert cURL to PHP?

Paste the command and pick PHP. The code uses PHP's cURL extension: curl_init, one curl_setopt call per option (URL, method, headers, body, basic auth), then curl_exec and the response status from curl_getinfo.

Can it convert cURL to Node.js?

Yes. The fetch output runs in Node.js 18 and later without packages. Pick axios if your project uses axios: the code calls axios with the method, URL, headers, data and auth, and logs the status and response data.

Which Java, C# and Rust versions does the code need?

Java code uses java.net.http.HttpClient from Java 11. C# code uses HttpClient with top-level statements, which compile on .NET 6 and later. Rust code uses reqwest's blocking client; add reqwest with the blocking feature to Cargo.toml as the first comment shows.

Does it support every cURL option?

No. It covers the options that shape the request. Others, such as -F multipart forms, --compressed, -k or --retry, are listed in a comment instead of being guessed.

What happens to --data @file.json?

The @file.json token is copied as written. The browser never reads the referenced file, so replace it with the file contents in your code.

Sources & last verified

We checked this tool's behavior and the claims on this page against the specifications below on . The tool runs in your browser, so the output you see is exactly what the engine produced. How we build and verify tools.

Last verified · Next review due

Found a wrong result or an outdated claim? Report an error and we will check it again.