Code Review Videos > JavaScript / TypeScript / NodeJS > Create A Postman Request From cURL

Create A Postman Request From cURL

A really simple one today, but one I had need of, and wasn’t sure was possible. That is to take a cURL request and import it in to Postman.

The clue is in italics above. However, I didn’t know this feature existed, and judging by the replies I got internally on Slack, neither did anyone else on the team. So I figured I’d share it here, and spread the love.

OK, so I can’t actually share the real request I needed this for. But it doesn’t matter, as the process is identical regardless.

You probably already know that you can convert a Postman request from the Postman client into other formats by clicking the </> code icon on the right hand side bar:

postman convert request to code

And there are a bunch of code snippet formats available:

postman convert request to code output formats

One of the formats is cURL:

postman convert request to curl

And cURL is most useful as you can run the command from your CLI and rule out any ‘funk’ in your own code. Essentially if the cURL request succeeds, you know the API / remote system is not at fault.

But what about when you have the cURL request and you want to run that from Postman.

I encounter this problem a lot when working with other people’s systems. It might be web scraping, or trying to reverse engineer some client code, or any other reason I can’t think of right now. Needless to say, this happens quite a lot.

How To Find Your Request in cURL Format

If you open Chrome developer tools, and find yourself an XHR request – something like you would find from a bit of JavaScript calling a remote API – then you can grab that request in a variety of formats:

chrome copy request as curl

From the Network tab, right click on the request you are interested in, then go to Copy > Copy as cURL.

Now, with this in your clipboard, go back to Postman and press the Import button:

postman import curl request

Depending on how new your Postman client is, you will see different things here.

On my Mac I got a simple text input field to paste in my request.

On Linux I get a full on pop-up box with a variety of options:

postman import pop up options linux

From there I have to select Raw Text:

postman paste in raw curl request

And when I do that, I get prompted to … do what I already thought I was doing:

postman confirm curl import

After which I see all the hard work is done for me:

postman successfully imported curl headers

And all I need to do is test the POST request:

postman post request

Which behaves as expected:

successful postman request outcome

I know this is in the docs, and a quick Google would have likely told me the answer. I just thought it was super neat and is exactly the kind of seemingly useless trivia I pick up when scanning other people’s blogs, that one day I will need and think, a-ha, I remember when that boring guy who never shuts up about trivial things told me all about how to do that!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.