

Online curl command line builder - tuxone
https://curlbuilder.com/

======
laumars
While I appreciate the idea and the work that's gone into this site, sadly it
seems too basic to be of much use. It only supports half a dozen flags - all
of which are easy to use normally anyway. It's missing user agent, headers,
cookies, etc. The latter two being items that could be particularly tricky for
the "curl novice".

Instead I'd probably recommend people use Chrome/Chromium's developer tools
which can export HTTP requests as curl commands:
[https://coderwall.com/p/-fdgoq/chrome-developer-tools-
adds-c...](https://coderwall.com/p/-fdgoq/chrome-developer-tools-adds-copy-as-
curl)

~~~
guava
It does seem to support custom headers, but as you stated doesn't support user
agents, cookies, etc.

~~~
laumars
Headers were added after my comment:

[https://news.ycombinator.com/item?id=9426493](https://news.ycombinator.com/item?id=9426493)

------
joemccall86
Seems pretty helpful, though for most of my endpoint testing I've switched to
httpie[1], and my teammates have followed. The only exception is when I need
to load-test a service real quick, and curl can make requests much faster than
httpie.

[1]
[https://github.com/jakubroztocil/httpie](https://github.com/jakubroztocil/httpie)

~~~
vially
I love httpie as well but recently I switched to bat [0] which offers pretty
much the same thing but is written in Go so is deployed as a single binary.

[0] - [https://github.com/astaxie/bat](https://github.com/astaxie/bat)

------
kstrauser
I'm a huge fan of "Paw" for OS X
([https://luckymarmot.com/paw](https://luckymarmot.com/paw)). After you
construct your query, it generates the equivalent code for curl, Objective-C
(NSURLConnection or AFNetworking), Python, jQuery, or several others. It also
now integrates with Mashape so you can download preconstructed libraries of
API calls.

Disclaimer: I have no connection with Paw's developers - I'm just a very happy
user.

~~~
spdustin
I am too. Especially the ability to configure "environments" to collect
variables you'll reuse, the export options (copy as curl, as jQuery.ajax, etc)
and the oauth workflow tools built in. Paw is a wildly useful tool.

\- another unpaid but wholly satisfied user

------
sleepyhead
Or use
[https://github.com/jakubroztocil/httpie](https://github.com/jakubroztocil/httpie)

~~~
tuxone
httpie is awesome, but in some environment all you have is curl.

------
vog
Nice idea, but this tool doesn't escape URLs properly. The biggest problem are
"&" characters, but also "?" characters make trouble in some shells (e.g.
zsh).

~~~
tuxone
Thank you for you feedback, does adding double quotes solve the problem?

~~~
Tiksi
Single quotes would be better, you can still run into trouble with things
getting parsed in double quotes.

Edit:

Example of this in zsh:

    
    
        # tiksi@layla  ~ 
        $ echo "http://example.com/uid=${thisisgone}-$(date)`pwd`\n\x00\x00nulletc\x0a"                                                                                                                                                                                                                                       [09:38:50] 
        http://example.com/uid=-Thu Apr 23 09:38:53 EDT 2015/home/tiksi
        nulletc
    
        # tiksi@layla  ~ 
        $ curl -vv -s "http://example.com/uid=${thisisgone}-$(date)`pwd`\n\x00\x00nulletc\0xb" 2>&1|egrep GET                                                                                                                                                                                                             [09:47:26] 
        > GET /uid=-Thu Apr 23 09:47:41 EDT 2015/home/tiksi\n\x00\x00nulletc\0xb HTTP/1.1

~~~
vog
Even single quotes need some additional escaping, see my other comment:
[https://news.ycombinator.com/item?id=9427820](https://news.ycombinator.com/item?id=9427820)

------
pkulak
I'm a big fan of right clicking on the request in the Chrome developer console
and selecting "Copy as cURL". Obviously only works if you're doing browser
stuff, but super helpful nonetheless.

~~~
zachrose
Indeed. I've been looking for an HTTP library that will let me get curl
representations of requests for debugging/collaboration. Something like:

    
    
      req = require('library').request(url, handler);
      console.log(req.toCurl());
    

Haven't found one yet.

------
mrfusion
I'd love to see things like this built for lots of complex command line tools.
I think awk would be really useful.

~~~
jaryd
Yeah, awk can be tricky. This tutorial[0] was posted awhile back and I
bookmarked it because I found it to be very useful. Check it out if you
haven't seen it.

[0] [http://ferd.ca/awk-in-20-minutes.html](http://ferd.ca/awk-
in-20-minutes.html)

------
VeejayRampay
Just for the info, Chrome (and possibly other browsers as well) allows to
build cURL commands from any network calls with a right-click on a HTTP call
in the Network tab.

------
fideloper
What I really want is for requestb.in (and friends) to generate a cURL CLI
command for me, just like Chrome developer tools does.

This would be useful for things like grabbing a test Stripe webhook sent to
requestb.in and sending it to your local dev server.

(I think there are some things you can host yourself to capture and replay
HTTP requests, however - I can't remember what they are)

~~~
seanp2k2
Chrome dev tools network tab -> right click on request -> copy as cURL is one
of my favorite features of chrome dev tools.

Another favorite of mine is the Tamper extension, which lets you edit js / css
and reload the page, having your edited versions served from mitmproxy:
[https://chrome.google.com/webstore/detail/tamper/mabhojhgigk...](https://chrome.google.com/webstore/detail/tamper/mabhojhgigkmnkppkncbkblecnnanfmd?hl=en)

------
rafaqueque
Good idea. It's quite difficult to remember all those parameters and command
structure. Thanks, bookmarked.

~~~
laumars
FYI, the command line already comes equipped with tools to lessen your needed
for remembering the various different flags:

    
    
       # invoke the curl manual:
       man curl
    

and

    
    
       # display a basic help file:
       curl -h

------
5h
Good timing, I was just after something to like this to include in some API
docs i'm handing over.

------
johns
This is really cool. You could tie the output to one of my projects:
embedcurl.com

This also makes me want to go back and add Copy as curl to hurl.it.

------
ecaron
@tuxone - Any chance of opening this up to accept PRs for adding new exposure
to curl features (like adding headers)?

------
euphemize
Cool, gimme a field to add a custom header (e.g. "Authorization" is pretty
common) and I'll use it!

~~~
Tiksi
Kinda defeats the purpose of using the tool, but headers in curl are pretty
simple:

    
    
        curl http://example.com -H 'Authentication: root' -H 'Password: p4ssw0rd'

~~~
seanp2k2
-H is for headers; yes, but basic auth is actually the base64-encoded string of user:pass , so if constructing it manually you'd want to do something like curl -H "Authorization: Basic $(echo -n 'user:pass' |base64)" [http://whatever](http://whatever) .

Curl provides a shortcut for this as --user; e.g. curl --user name:pass
[http://example.com](http://example.com)

Try it yourself with -vvv to see all the headers from both ends. Ref:
[http://curl.haxx.se/docs/httpscripting.html#Basic_Authentica...](http://curl.haxx.se/docs/httpscripting.html#Basic_Authentication)

http basic auth protocol:
[http://en.m.wikipedia.org/wiki/Basic_access_authentication](http://en.m.wikipedia.org/wiki/Basic_access_authentication)

~~~
Tiksi
You can also use curl --negotiate -u : for kerberos (provided curl is built
with it and spengo). curl supports quite a few less used auth methods, but OP
mentioned custom headers, not basic auth per se, (thats why I used
Authentication instead of WWW-Authenticate or Authorization as an example)

------
amelius
Doesn't work with tcsh.

Does anybody know how to escape curly braces on tcsh?

------
Gonzih
why not just man curl?

~~~
kstrauser
There's a lot of benefit in something that can properly escape data, for
instance. I'm totally comfortable with curl but sometimes physically typing
the command line is harder than deciding what should go in it.

------
niix
Nice, this is really helpful.

------
_mikz
what is so hard about remembering how to use curl?

I was hoping for some JS library that would generate the commands with proper
escaping etc.

~~~
tuxone
I have two "problems" with curl. First I have to remember every kind of HTTP
header (no autocomplete) and second write/edit command lines (especially JSON
bodies etc) is a bit unfriendly.

Of course this is just a 10 minutes experiment.

------
ripkirby
Read the man pages

