{ Curl to Code }

// paste curl → get code in any language

Convert cURL commands to JavaScript (fetch/axios), Python (requests), PHP (Guzzle), Go, and Ruby code instantly. Free, browser-based, no sign-up.

Paste any cURL command — multi-line with \ is supported
// examples:

Ready to convert

Paste a cURL command and click Convert

HOW TO USE

  1. 01
    Paste your cURL

    Copy any cURL command from your browser DevTools, Postman, or API docs. Multi-line commands with \ are supported.

  2. 02
    Select a language

    Pick your target — JS fetch, axios, Python requests, PHP cURL, PHP Guzzle, Go net/http, or Ruby Net::HTTP.

  3. 03
    Copy or download

    Click Convert, then copy the code to clipboard or download the file directly into your project.

FEATURES

7 Languages JSON body detection Auth support Custom headers Multi-line cURL File download

USE CASES

  • 🔧 Translate API docs examples into your stack
  • 🔧 Port Postman exports to application code
  • 🔧 Learn HTTP request patterns across languages
  • 🔧 Scaffold API integration boilerplate fast

WHAT IS THIS?

Curl to Code parses a raw curl command and outputs equivalent HTTP request code in your chosen programming language. It handles methods, headers, request bodies, authentication, and multi-line syntax — producing clean, copy-paste-ready code with zero configuration.

RELATED TOOLS

FREQUENTLY ASKED QUESTIONS

Does this tool send my cURL command to a server?

The conversion happens via a lightweight PHP parser on the same domain — your cURL command is never stored, logged, or shared with any third party. Only the current request is processed and returned.

What cURL flags are supported?

The parser handles -X, -H, -d, --data-raw, --data-binary, -u, --json, -L, -k, and most common flags. Unknown flags are gracefully skipped without causing errors.

Can I convert multi-line cURL commands?

Yes. Commands split across lines with a backslash \ continuation — as commonly copied from browser DevTools or API docs — are automatically normalized before parsing.

Does it handle JSON request bodies correctly?

Yes. When a Content-Type: application/json header is present or the --json flag is used, the tool uses JSON-aware output — e.g., json=payload in Python and the json key in Guzzle.

Which programming languages are supported?

JavaScript (native fetch and axios), Python (requests), PHP (native cURL extension and Guzzle HTTP client), Go (net/http), and Ruby (Net::HTTP). More languages may be added in future versions.

How does Basic Auth conversion work?

If your cURL uses -u username:password, the tool converts it to the appropriate auth mechanism — auth=(user, pw) for Python, req.SetBasicAuth for Go, and request.basic_auth for Ruby.

What is the difference between PHP cURL and PHP Guzzle output?

PHP cURL uses the native curl_* functions built into PHP, with no dependencies. PHP Guzzle uses the popular GuzzleHttp library, preferred in Laravel and Symfony projects for its cleaner API and PSR-7 compliance.

Can I download the generated code as a file?

Yes. Click the ↓ Download button after converting to save the code as a .js, .py, .php, .go, or .rb file — named request.ext automatically based on the selected language.

What is a cURL to Code Converter?

A cURL to Code converter is a developer utility that parses a raw curl command and outputs equivalent HTTP request code in a programming language of your choice. Instead of manually rewriting HTTP logic from scratch, you paste the cURL command and get production-ready code instantly — preserving all headers, the request method, authentication, and the request body exactly as specified.

cURL is the universal lingua franca of HTTP APIs. Almost every API documentation page shows examples as cURL commands, every browser DevTools network panel has a "Copy as cURL" option, and tools like Postman and Insomnia can export requests as cURL. The problem is that your application code is never actually cURL — it's JavaScript, Python, PHP, Go, or Ruby. That's where this converter bridges the gap.

How Does the cURL Parser Work?

The converter first normalizes multi-line cURL commands (those split with \ line continuations) into a single string. It then tokenizes the command, respecting both single-quoted and double-quoted arguments, and walks through the flags sequentially:

The parsed structure — URL, method, headers map, body string, and auth — is then passed to the appropriate code generator for the selected language.

JavaScript: fetch vs axios

The JavaScript fetch output uses the native fetch() API available in all modern browsers and Node.js 18+. It generates clean async/await code with an options object containing method, headers, and body keys. The JavaScript axios output uses the popular axios library, widely used in React, Vue, and Node.js projects for its cleaner API, automatic JSON serialization, and built-in request/response interceptors.

Python: requests Library

The Python output uses the requests library — the de facto standard for HTTP in Python. When the request body is detected as JSON, the converter uses the json= parameter rather than data=, which automatically serializes the payload and sets the correct Content-Type header. Basic Auth is converted to an auth=(user, password) tuple.

PHP: Native cURL vs Guzzle

PHP developers have two main options. The native PHP cURL output uses curl_init(), curl_setopt_array(), and curl_exec() — functions available in every standard PHP installation without any dependencies. The Guzzle output uses the GuzzleHttp client, a modern, PSR-7 compliant HTTP client preferred in Laravel, Symfony, and other framework-based projects for its expressive API and middleware support.

Go: net/http Package

The Go output uses the standard library net/http package — no third-party dependencies required. The generated code creates an http.Client, builds a typed http.Request, sets headers individually via req.Header.Set, and reads the response body with io.ReadAll. Basic Auth is handled via the idiomatic req.SetBasicAuth() helper method.

Ruby: Net::HTTP

The Ruby output uses the built-in Net::HTTP module from the standard library, requiring no external gems. The converter selects the correct request class (Net::HTTP::Post, Net::HTTP::Get, etc.) based on the detected HTTP method, and handles SSL connections automatically by checking the URI scheme.

Why Convert cURL to Code?

Developers encounter cURL commands constantly — in API documentation, Stack Overflow answers, internal wikis, and browser DevTools. Converting them by hand is tedious and error-prone, especially when dealing with complex headers, Bearer tokens, or JSON payloads with nested structures. A converter eliminates copy-paste errors and reduces the time from reading an API example to having working application code.

This tool is particularly useful for: integrating third-party REST APIs into your application, translating Postman collections or browser DevTools exports into framework code, learning how HTTP requests are structured across different languages, quickly scaffolding API integration boilerplate, and onboarding new team members who are more familiar with one language than another.

Tips for Best Conversion Results

For the most reliable conversion: always include the curl keyword at the start of your command; wrap URLs and header values in single quotes if they contain special characters; use --data-raw instead of -d for JSON bodies to avoid shell interpretation issues; and make sure your Content-Type header is explicitly set so the converter can detect JSON payloads and use language-native JSON handling methods automatically.