Cookies This site keeps only what it needs to work. There is no analytics and no advertising on it today, and nothing here follows you to other sites. Read the privacy policy

Choose what to allow
+92 312 8299940Free Quote
Free tool, no account needed

curl Converter
Turn One Command Into Code

This curl converter turns one command into running code. Choose PHP, Python, JavaScript, Go, Ruby, Java, C# or raw HTTP. So you paste once, then you stop retyping headers by hand. The work happens in your browser, and we upload nothing.

  • FreePrice
  • ThirteenLanguages
  • NoneSign-up
  • NoneUploads

curl Converter

Turn one curl command into PHP, Python, JavaScript, Go, Ruby, Java, C# or raw HTTP

Ready. Paste a curl command, or press Try a sample.

Your browser does all of the work here, in this tab. We upload nothing, store nothing and log nothing.
The short version

What A curl Converter Does

A curl command writes a request as a command line. This curl converter turns that one line into code you can drop into a project. Therefore the header you copied from devtools keeps its exact value, and you stop retyping it.

Four things come back from one paste. First, the request itself: method, address, headers and body, read back so you can check them. Then the code in the language you picked. After that, the switches curl would have applied, such as redirect following or a timeout. Finally, a list of anything the reader had to decide on its own.

That last list matters more than it looks. A silent guess inside generated code is a bug you find in production. So the page prints every decision next to the code instead.

You install nothing and you send nothing. So you paste a command, read the code, and close the tab when it suits you.

How A curl Converter Reads A Command

The work splits into three passes. First, the page splits the command into words the way a shell does. Then it reads each word as a flag, a value or the address. Finally it hands the request to a writer for the language you chose.

Diagram of the three passes a curl converter makes: a curl command with three headers and a JSON body on the left, three numbered steps in the middle reading split the words as a shell would, mark each word a flag a value or the address, and hand the request to a writer, and the same request on the right as a PHP script with the address, the headers and the body already filled in
Split the words, read the flags, then write the request out.

The splitting follows the shell rules for quoting, because a command pasted out of devtools leans on them. A body inside single quotes is one word even when it holds spaces. A backslash at the end of a line joins it to the next one.

Reading flags is where a converter earns its keep. Because curl lists over two hundred options, only some are worth carrying. The ones that matter change what a server sees. Those are the method, the headers, the body, the cookies, the redirects and the timeout. The page reports the rest rather than guessing at them.

The writers never touch the network. So the page works offline. It also works on a machine with no curl installed. A command can point at an address your browser cannot reach, and the page still converts it.

Why Quoting Is The Hard Part

A converter that splits on spaces alone gets most commands wrong. Because a header value often holds a space, a naive split cuts it in two. Then the code carries half a token and the request fails with a 401.

So the reader tracks the quote state as it walks the line. A double quote groups a run of words into one, and a single quote does the same without any escaping inside it. Only a quote that opens and closes at the right places counts.

A backslash is the third case. Outside quotes it escapes the next character, and before a newline it removes the newline itself. That is why a command pasted across twenty lines still reads as one command.

Which Languages It Writes

Thirteen targets cover the work most people bring here. For PHP there is plain cURL and the Guzzle client. For Python there is requests. For JavaScript there is fetch, axios and the Node.js http module. Go, Ruby, Java and C# each get one. Then come raw HTTP, a cleaned-up curl line, and JSON.

Screenshot of the generated code box with the Python requests target selected: the sample request written out as a script that imports requests, keeps the orders address intact, builds a three-line headers dictionary with the bearer token in place, passes the JSON payload as one string, then calls post with verify and allow_redirects both true and a twenty second timeout, and prints the status and the body
The same request as Python, with the headers and the body byte for byte.

Each writer is a small function over the same request object. Because of that, every target sees identical bytes. The body sent by the PHP sample is the body sent by the Go sample. Nothing trims a header per language or quietly reformats the payload.

The PHP and Python writers aim at code you can run as-is. So the PHP one opens with the tag, sets the options and closes the handle. The Python one imports requests, builds the headers and prints both the status and the body.

JavaScript splits three ways on purpose. Fetch ships in the browser. Axios brings its own conveniences, and the Node.js http module suits a script with no dependencies. So all three earn a place.

Two targets are for reading rather than running. Raw HTTP prints the message as it would go over the wire. That is the fastest way to see whether a header is really there. JSON prints the same request as data, ready for a test fixture.

What The Read-Back Panel Shows

Before any code appears, the page prints the request it understood. Nine facts each get a line. They cover the method, the address, the header count, the body size and the content type. The authorization, the cookies, the switches and the timeout follow.

Screenshot of the read-back panel below the generator: nine facts in a grid reading method POST, the orders address with a status query, three headers, a request body of fifty-three bytes, content type application slash json, authorization set by a header, no cookies, the switch follow and a timeout of twenty seconds, with the header list underneath showing accept, content type and authorization one per line, the last carrying a masked bearer token
The request is read back before the code is written, so a lost header shows up here.

The addresses are not the interesting part. Rather, the point is the check. A header that went missing shows up here before you paste anything. So does a body that arrived as a form instead of JSON. A password in the wrong place shows up too.

The page prints the header list in full underneath, one header per line. Therefore you compare what curl would send against what your server expects. Then the difference is visible rather than assumed.

The panel names switches in plain words. A reader of the code should not have to know that -L means follow redirects. The panel says follow, insecure, compressed or silent instead.

From Devtools To A Script In One Paste

The usual way in is the browser. Every large browser can copy a request as curl. So open the network panel, right-click the call that failed, copy it, and paste it here. The command arrives with the real headers, the real body and the real cookies.

Screenshot of the decision notes under a converted command: one line explains that a multipart body is built here and sent as raw bytes, and that a file part is a placeholder because the page cannot read your disk
Anything the reader had to decide is printed beside the code, not hidden in it.

That is also the usual way to debug a private call. So you reproduce a failed request as code. Then you add a print and watch what the server says, instead of guessing from a network panel.

Line breaks do not matter. Therefore the page reads a command copied across twenty lines the same way it reads one line. Indentation does not matter either.

Step by step

How To Use The curl Converter

Four steps, and none of them need an account.

  • 1

    Copy the command

    So open devtools, right-click the request, and pick Copy as curl. From a doc or a README, select the whole command including any backslashes at the end of a line.

  • 2

    Paste it in the left box

    Then paste the whole thing. The box takes the command exactly as you copied it. So there is no need to join the lines or tidy the indentation first.

  • 3

    Check the read-back panel

    Next, compare the facts against what you expect. A missing header is easier to spot here than in the code below. So is a body that arrived as a form.

  • 4

    Pick a language and take the code

    Finally, choose a target, then copy or download it. Also read the decision notes: the page lists anything the reader guessed at, on purpose.

Why this page

Why Use This curl Converter

Four reasons, and each one is about the request rather than the code.

  • One paste, thirteen targets

    So you compare two languages side by side and settle the argument about which header is missing. Because the same request feeds every writer, the samples agree with each other by construction.

  • Nothing leaves the browser

    Therefore a bearer token or a session cookie stays on your machine. There is no upload, no log and no account. That matters when a command carries a live secret.

  • The page prints every guess

    Because a silent guess inside generated code is a bug you find later, the page lists every decision next to the code, with the flag it came from.

  • Every PHP sample passes php -l first

    Then the build writes every PHP sample to a file. It runs each one through php -l before the page goes live. So quoting mistakes are caught here rather than in your editor.

Rules it follows

The Rules This Converter Keeps

Six rules, and they are what makes the output trustworthy rather than merely plausible.

  • The method comes from the command An explicit -X wins. Otherwise curl rules apply. A body makes it a POST, a HEAD switch makes it a HEAD, and the rest stay GET.
  • A declared content type beats a default Devtools always sends the header. So the code carries the value you copied, even when curl would have guessed something else.
  • Repeated body parts join with an ampersand So three -d flags become one form body, exactly as curl sends them. The page says it joined them, so you know.
  • Basic auth is built, not copied Then the user name and password from -u become one Authorization header. So the code sends the same bytes without needing curl to do it.
  • Nothing is sent anywhere The reading and the writing both run in your browser. So a command pointing at an internal host still converts fine, and no request is ever made.
  • A refusal is a result So the page reports a flag with no equal in the target language. It never drops that flag silently. Then you decide what to do, with the flag named.
Careful here

Mistakes To Avoid With Generated Requests

Six things people get wrong, and how to sidestep each one.

  • Pasting a command with broken quotes

    Watch out when a shell or a chat window has stripped the outer quotes. Because an unclosed quote swallows the rest of the line, check the closing mark before you blame the converter.

  • Leaving a real token in the sample

    Therefore replace a live bearer token with a placeholder before you commit the file. The converter keeps the value you gave it, so the tidying is yours to do.

  • Trusting a header read from a file

    A -H @file flag means the header lives on disk. Because this page cannot open your disk, the header is missing from the code, and the note says so.

  • Forgetting that redirects differ by default

    So curl does not follow a redirect unless you pass -L. Several HTTP clients follow by default, which is a difference that bites. The panel names the choice the command made.

  • Pasting a multipart body and expecting a real file

    This page cannot read the file you named. So the body carries a placeholder, and you swap in the real path later. Your client library can build the multipart form itself.

  • Assuming every language quotes the same way

    A body holding an apostrophe breaks a careless PHP string and a careless Python string in different places. Therefore each writer escapes for its own language, and the build lints the PHP ones.

Questions

curl Converter Questions

Is this curl converter free?

Yes. There is no account, no limit and no paid tier. So you convert as many commands as you like.

Does it send my command anywhere?

No. Because the reading and the writing run in your browser, the command never leaves your machine. Therefore a request carrying a live token stays private.

Does it run the request?

No. It only reads the command and writes code. So nothing goes to the address in the command, which is what makes an internal host safe to paste.

Which languages can it write?

Thirteen targets. For PHP there are two: plain cURL and Guzzle. Python gets requests, and JavaScript gets fetch, axios and the Node.js http module. Go, Ruby, Java and C sharp each get one. The last three are raw HTTP, a cleaned curl line and JSON.

Can it read a command copied from Chrome or Firefox devtools?

Yes. That is the main way in. Then the copied command arrives with its quotes and backslashes, and the reader handles both.

What about a command written on one very long line?

It reads the same. The splitter works on whitespace and quotes rather than on lines. So a single long line and twenty short ones give the same request.

Does it understand --data-raw, --data-binary and --data-urlencode?

Yes, and each keeps its own meaning. So a urlencoded part stays encoded, and a binary part goes through as written.

What happens with -F file uploads?

The page builds the multipart body itself and sends it as raw bytes. Because it cannot read your disk, a file part carries a placeholder, and the note says which one.

Does it follow redirects like curl does?

It matches the command. So curl does not follow a redirect without -L, and the code follows only when the command did.

How does it handle -u user:password?

It builds the Authorization header itself from the two parts. As a result the generated code sends the same Basic header without needing a curl option.

Why does a flag show up under the decision notes?

Because the reader either had to choose for you or had to leave something out. Then the note names the flag, so you can check it by hand.

Can I convert a curl command that has no address?

Partly. Then the page reads and reports the flags, but there is no request to write. It asks for an address instead.

Can I run the generated PHP as it is?

Yes. It opens with the tag, sets the options, executes and closes the handle. Also it goes through php -l before this page goes live, so the quoting holds.

And the generated Python?

It imports requests, builds the headers, sends the call with the right method and prints the status and the body. So you paste it into a file and run it.

Why does fetch need a redirect setting?

Because the browser default differs from curl. So the code names follow or manual, and both match what the command asked for.

Does it keep header order?

Yes. The code writes the headers in the order they appeared in the command. So a diff against the original line is readable.

Can it read a cookie file?

The page reports the path, but it does not open the file. Because a browser cannot read your disk silently, it invents no Cookie header from it.

What does the clean curl target do?

It writes the same request back as a tidier curl line, with one flag per line. So you can paste it into a script or a ticket and see every part.

What is the JSON target for?

It prints the request as data. Then you drop it into a test fixture and compare what your code sends against what curl sent.

Does it handle --json?

Yes. That switch sets both the content type and the accept header, and the panel shows both. When a plain body part mixes in, the page says the combination is ambiguous.

How many headers can it take?

Hundreds. The reader is a single pass over the words. So a command with three hundred headers converts in the same instant as one with three.

Does it work on a phone?

Yes. The boxes stack, and the sample stays readable at a narrow width. So you can convert a command while you are away from a desk.

Can I use the output in a commercial project?

Yes. There is no licence on the generated code because generated code is yours, and nobody asks for attribution.

Why does the code sometimes carry a comment?

Because the target language has a place to explain itself. So the code spells out a switch with a surprising meaning where the reader of the file will find it.

What if the converter reads a flag I have never seen?

The page reports it as an unknown flag and skips it. Above all, it invents nothing in its place, which keeps the rest of the request honest.

Is there an API?

No, and there is no need for one, because the work happens in your browser already. That is also why nothing reaches a server log.

Keep going

Tools That Go With This One

Four pages the same job usually leads to.

  • JSON formatter

    Then pretty-print the body of the request before you paste it into a fixture. Because a one-line payload hides a bad key, this makes it obvious.

    Open tool →
  • URL encoder and decoder

    Also check a query value that came through --data-urlencode. Then you see whether the percent signs are right before a server rejects them.

    Open tool →
  • HTML entity encoder and decoder

    For a request body that carries markup, this shows what the server will really read. So an escaped ampersand stops being a guess.

    Open tool →
  • JavaScript minifier

    After you paste the fetch sample into a project, this shrinks it for the browser build. Then the file that ships stays small.

    Open tool →

Convert A curl Command Now

Paste the command, check the request that comes back, and take the code in the language you need. Nothing leaves your browser, so a token stays yours. The whole job takes one paste.