cURL to Code
Convert cURL commands to Python, JavaScript, PHP, Go, Java, C# and Ruby
Quick examples
Multi-line commands with backslash continuation are supported.
Paste any curl command above โ from API docs, Postman exports, or your terminal history.
Supports -X ยท -H ยท -d ยท -u ยท -b ยท -F ยท -L ยท -k ยท --max-time
About this tool
The ToolNinja cURL to Code Converter transforms any cURL command into clean, ready-to-run code in 8 programming languages. Paste your curl command and get Python requests, JavaScript fetch, Node.js axios, PHP cURL, Go net/http, Java HttpClient, C# HttpClient, or Ruby net/http code โ with headers, authentication, request body, cookies and timeouts all correctly translated. Developers constantly encounter curl commands in API documentation, Postman exports, Stack Overflow answers and terminal history โ and need to translate them into application code. Doing this manually is error-prone and slow. ToolNinja handles it automatically, supporting all common flags: -X (method), -H (headers), -d/--data/--data-raw (body), -u (basic auth), -b (cookies), -F (multipart), -L (follow redirects), -k (insecure), --max-time (timeout) and more. Switch between all 8 languages instantly without re-pasting the command. Download the generated code as a file (.py, .js, .php, .go, .java, .cs, .rb) or share the curl command with a direct link. 100% client-side. Your API endpoints, tokens, keys and request data never leave your browser.
When to use it
- โConverting Postman-exported curl commands to Python for test automation scripts
- โTranslating API documentation curl examples to JavaScript fetch or axios
- โTurning terminal curl history into Go or Java code for microservices
- โConverting curl commands to PHP for server-side API integrations
- โTranslating curl to C# HttpClient for .NET applications
- โLearning how different languages implement the same HTTP request
Tips
- โMulti-line curl commands with backslash continuation (\) are fully supported โ paste them as-is.
- โJSON bodies (-d with Content-Type: application/json) use the language-native JSON method โ no manual serialization.
- โSwitch between all 8 languages instantly without re-pasting the command.
- โDownload the file directly โ .py, .js, .php, .go, .java, .cs, .rb โ ready to run with no changes.
Frequently asked questions
What curl flags does this converter support?
Supports all common flags: -X (method), -H (headers), -d/--data/--data-raw/--data-binary (body), -u (basic auth), -b/--cookie (cookies), -F/--form (multipart), -L (follow redirects), -k/--insecure (skip SSL), --max-time (timeout), -A (user agent), -e (referer), --data-urlencode, and -I/--head.
Is my curl command sent to any server?
No. All parsing and code generation happens in your browser. Your API endpoints, authentication tokens, API keys, headers, and body data never leave your machine โ completely safe for real credentials.
Why does my Python code use json= instead of data=?
When curl sends JSON (-d with Content-Type: application/json), the Python converter uses json= which automatically serializes the dictionary and sets the correct Content-Type. Use data= only for raw string bodies or form-encoded data.
How do I convert a Postman request to Python code?
In Postman, click the </> Code button in the right sidebar, select cURL from the dropdown, copy the command, then paste it into ToolNinja's cURL to Code converter and select Python. The generated code is ready to run.