Turn a cURL request into Node.js code using Request
Paste a cURL command and get an equivalent Node.js snippet built around the Request library.
This page is for developers who already have a working command-line request and want to move that same request into JavaScript without rebuilding its method, URL, headers or body by hand.
How the conversion works
Use the converter in three steps:
- Paste the complete cURL command into the input field (control0003). The field starts with the placeholder example "curl example.com".
- Review the generated Node.js with Request output in protected module code0001.
- Use the "Copy to clipboard" control (control0004) to copy the snippet into your project.
Before running the result, check that the URL, HTTP method, headers, authentication values and payload still match the request you intended to reproduce. Treat copied credentials or tokens as secrets and remove or replace them before sharing code.
A checklist for moving from cURL to Node.js
A practical workflow is:
- Capture the request in the browser or from documentation so you have a known-good cURL command.
- Paste that command into the converter and inspect the Node.js with Request equivalent.
- Compare the generated options against the original command, especially the method, URL, headers and request body.
- Run the snippet in your own Node.js environment and adjust error handling, timeouts and response parsing for your application.
- Keep the original cURL command alongside the generated code while you test, so you can diff behaviour if the two requests diverge.
Getting a cURL command from your browser
If you do not yet have a cURL command, start from a browser request. The browser-specific guides cover Chrome, Safari and Firefox. Once you have copied the request as cURL, return to the converter above and paste it into control0003.
What to do after the request works
JavaScript is a good fit for this task because the same language can build web applications and services and can also fetch and parse web content. For the next step after making a request, the linked tutorials cover parsing HTML and extracting data with jQuery, using the Cheerio NPM package, and web scraping with Node.js.
Choosing a different converter target
Request is only one of several JavaScript and non-JavaScript targets. If you prefer a different HTTP client or language, the related converters include Node.js with Axios, Node.js with fetch, JavaScript Fetch, Python, Go, Java, PHP, Rust, R, Dart, Elixir, CFML, JSON and MATLAB. Choose the target that matches the codebase you are adding the request to, rather than converting to Request and then rewriting it again.
Frequently asked questions
How do I get a cURL command from a browser request?
Open the browser's request-inspection tools for the page or action you just performed, locate the network request you want to reproduce, and copy it as a cURL command. Guides are listed for Chrome, Safari and Firefox.